Parallel computing with GHPython


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 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


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.

for key in keys:
def F(key):
#do something
#create dictionary1 and dictionary 2
tasks.Prallel.ForEach(keys, F)
for key in keys:

Sorry, no indent.