[Bf-python] Blender Python & Threading?

Nathan Letwory jesterking at letwory.net
Tue Jun 16 21:49:55 CEST 2009


If you ever continue with the threads part, you can tweak how many
virtual instructions are executed before the python core checks for
thread switches etc. do that with sys.setcheckinterval(int) . That is
what Willian found out during tests with pynodes in a threaded
renderer.

/Nathan

2009/6/16 Toni Alatalo <antont at kyperjokki.fi>:
> On Jun 16, 2009, at 10:23 PM, joe wrote:
>
>> Ok, so technically it's normal threads, that are serialized via the
>> GIL.  That's just semantics though :)
>
> well on a single core machine they work like normal threads, are not
> 'serialized' in that sense.
>
>> 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.
>
> i don't think that's true, doesn't the os switch between the threads
> being executed .. also within bpython. at least that's what i thought
> it was doing when tested them for some networking thing ages ago.
>
> tested now and it does work, http://an.org/blender/thread.py source and
> how it execs in blender below too:
>
> import threading, time
>
> def hello():
>        print "Hello!"
>
> t = threading.Timer(5, hello)
> t.start()
>
> for i in range(10):
>        print i
>        time.sleep(1)
>
> """prints:
> 0
> 1
> 2
> 3
> 4
> Hello!
> 5
> 6
> 7
> 8
> 9
> """
>
> GIL just means it doesn't use multiple processors for that within a
> single process.
>
> ~Toni
>
> _______________________________________________
> Bf-python mailing list
> Bf-python at blender.org
> http://lists.blender.org/mailman/listinfo/bf-python
>
>



More information about the Bf-python mailing list