I have multiple environments (DEV, INT, PRD). I will like to build each environment asynchronously using python multiprocessing.
In my example below, build_environments is a list as such : ['DEV', 'UAT', 'PRD'].
def thread_set(self,environment):
max_workers = 3
concurrent = futures.ThreadPoolExecutor(max_workers)
with concurrent as ex:
ex.map(self.build, environment)
return environment
def multibuild(self):
build_environments = self.myparser.getEnvironments()
with multiprocessing.Pool(processes=4, maxtasksperchild=1) as pool:
results = pool.imap(self.thread_set, build_environments)
pool.close()
pool.join()
def build(self,build_environment):
print(build_environment)
When i execute multibuild(), the print statement in build() function is printing and executing in this manner as shown below.
U
A
T
D
E
V
P
R
D
But I will want the build() print function to be :
DEV
UAT
PRD
What could be the issue ?