Running 2 loops in parallel threading - Ironpython

I’m calculating intersections and the entire plugin takes 60seconds per solid in the model, based on how big the model is.
Now the problem is that our models count around 2000solid parts…
Any idea?

@stevebaer I found your post but I could not really apply to this case.
If you could help me out in applying it to this case It’d be nice of you
Thanks in advance.

@dale could you help me out or anyone?
I tried the CNC cutting on a ship block, there are roughly 500parts, it takes 7hours to process all parts.

Hi @farouk.serragedine,

Parallel threading isn’t too hard.

from threading import Thread

def func1():
    for i in range(0,1000):
        print('func1 working')
    print('func1 done')        

def func2():
    for i in range(0,1000):
        print('func2 working')
    print('func2 done')        

if __name__ == '__main__':
    Thread(target = func1).start()
    Thread(target = func2).start()

Writing thread-safe code can be hard, and thread syncronization can be a challenge.

There a lot of info on thread with Python and with .NET on the web. You might spend some time in Google.

– Dale

Thanks resolved, wasnt too hard in the end.
Using C# would’ve made things much easier. I had no idea threading was supported in ironpython 2
Thanks Dale have a great day!

For anyone who has the same issue
Threading didnt solve my problem, ironically threads slowed the program down.
Probably a bad implementation, anyhow I do not believe threading is a solution to most peoples, rather a niche solution to some problems. Not worth the time investment imo in the enviroment of Rhinoceros. Use rhinocommon instead.

1 Like