Hello,
I’m testing parallel computing with Python (Grasshpper, Rhino 6, Windows 10, 64bit)
I have a Python script which takes 3mins to complete and I rewrote it with both ghpythonlib.parallel.run and System.Threading.Tasks.Prallel.ForEach.
Both worked and now it runs in 1min. However, It crashes on every second run.
The result seems fine and it completes the first run safely always. It crashes on the second run.
Unfortunately I cannot post the script but if somebody suggest me what’s in general this case is mostly like I’ll be appriciate very much.
I have done a lot of this. I get crashes if the parallel operations try to store to the same object (list, array, etc). To avoid this I organize the parallel threads to store their results in their own list. Then after all the parallel threads are done, I combine the results. Is this what you are doing? But this may not be your case as I did not get crashes on every second run
Regards,
Terry.
Thank you for your reply. I have a dictionary which have all the keys before running the parallel process. It crashed when I started with an empty dictionary. But as you said, the problem is it crashed on the second run…
My code is roghly like this.
dict={}
for key in keys:
dict[key]={}
def F(key):
#do something
#create dictionary1 and dictionary 2
dict[key]=(dictionary1,dictionary2)
tasks.Prallel.ForEach(keys, F)
#merge
d1={}
d2={}
for key in keys:
dd1,dd2=dict[key]
d1[key]=dd1
d2[key]=dd2