Question: I am using below code snippet for deploying code to multiple environments parallelly . For example I have two environments acpt, acpt2. The function
Deploy executes from shared library which loaded at first to below script . The problem is when it tries to deploy first environment “acpt” as its parallel stage it moves to “acpt2” environment and it never deploys to acpt environment. How to get around this issue ? Any thoughts?

```
    stage('Deployment Distribution') {
        steps {
            script {

                    for (int i = 0; i < environments.size(); i++) {
                    env.environ = environments[i]
                    jobs["${env.environ}"] = {

                        node("XXXXX") {

                            stage("Deploy ${env.environ}") {

                            Deploy("${env.environ}")  /// This function is written in shared library

                            sleep 10

                        }
                    }
                }
            }
                parallel jobs
            }
        }
    }

```

Answer: 
A more efficient way to do this is with:

```
id = 123
attribute = 'title'
value = 'New Title'
Stuff.objects.filter(id=id).update(**\*\*{attribute: value}**)
```

This will prevent first fetching the object with a query, and then update it.

If you need to load the object anyway, you can work with [**`setattr(…)`** [Python-doc]](https://docs.python.org/3/library/functions.html#setattr):

```
id = 123
attribute = 'title'
value = 'New Title'

item = Stuff.objects.get(id=id)
**setattr(**item, attribute, value**)**
item.save()
```
Try using an if statement like

```
If attribute = 'title'
    item.title = value
    item.save()

```