Multithreading support (please :) )

Yes, I also suggested that somewhere above :wink:

The context isnā€™t passed to another thread, as the addSimpleCube function is called from the main thread.

Yea, I had a fast look on the docsā€¦ was not able to match the ā€œforever listeningā€ spinning task in there. But I will give it another try soon, to see how easy it is to achieve the same concept

https://wiki.blender.org/wiki/Reference/Release_Notes/2.91/Python_API release notes claims theyā€™ve fixed it but it still spawns multiple Blender instances for me on 2.91:

with Pool(4) as p:
        r = p.map(mp_flip, pixels)

Just noticed this thread guys - BlenderKit add-on is using lots of threads and basically the logic is similar.
Either the thread writes to own data that can be read, or it puts commands into queue that get executed from a timer. However, there is a problem with the timers currently, since accessing any type of context or bpy stuff from them currently might cause a crash (at least seems so). Threading seems to be quite stable, but you really need to be careful before passing any data to threads - always deepcopy any custom properties e.t.c.

2 Likes