algorithmic modeling for Rhino

Multithreading, Race condition's trouble | ghPython parallel modules + SurfaceMorph

if not using paralle modules ....

if using paralle modules ....

why this...

please help me !!


import ghpythonlib.components as ghcomp
import ghpythonlib.parallel

model = []

def SrfMorph(myS):
    result = ghcomp.SurfaceMorph(G,R,myS,U,V,W)
    if result:
        return result

if parallel:
    model =, S, True)
    model = ghcomp.SurfaceMorph(G,R,S,U,V,W)


Views: 971


Replies to This Discussion

Hi Shuta,

I guess it's a bug of some sort.
Interestingly the problem goes away when you graft the "S" input.

Hi djordje

thx for your advice!


if graft the "S" input...

the component run as "single thread"...

<graft - 563 ms>

<not graft - 256ms>

Having higher component's run time in parallel mode, than in single thread mode, is not an indication that parallel mode is running in single thread mode too.
The reason why you might have higher time if you graft the "S" input is because function is meant to be used with single lists (being that a python regular list or a list from a single branched grasshopper tree), or python's lists of lists. When you graft "S" input, you get a data tree with several branches, with one list on each of those branches. Because of this then needs to take one list at a time, and an item from that list, which results in much higher component run time.

I reported the problem at ghpython's github issues page.



Thanks for your information !
I read the article carefully.
But, I was not able to solve this problem...

In this article, "race condition" is not described.

It looks like SurfaceMorph is not thread safe. I created an issue in our bugtracker to fix this in the future.

For now, you should not use multiple threads for the SurfaceMorph functionality.






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service