[Bf-python] Blender Python & Threading?

joe joeedh at gmail.com
Tue Jun 16 21:23:39 CEST 2009


On Tue, Jun 16, 2009 at 1:15 PM, Toni Alatalo<antont at kyperjokki.fi> wrote:
> On Jun 16, 2009, at 10:03 PM, joe wrote:
>
>> No it's not, python uses "green threads", and it requires additional
>> support on the py c api side (which none of us have figured out yet,
>
> huh? i thought it's normal threads.

Ok, so technically it's normal threads, that are serialized via the
GIL.  That's just semantics though :)

>
> you can create them, but don't expect the api to be thread safe ..
> having a thread that does something else and doesn't call blender might
> work ok. then a normal py thing run by blender could communicate with
> that.

I believe you have to explicitly release the GIL (and reacquire it) in
the main thread for threads to really work at all.  What happens, is
that the extra threads only get run when a python script gets events,
and is pretty much dead the rest of the time.

>
> often though when you think you need threads, you don't, depends on the
> prob.
>
>
> ~Toni
>



More information about the Bf-python mailing list