[Stackless] Mixing os threads and stackless
lars at ibp.de
Wed Apr 26 13:31:26 CEST 2006
> I don't *think* you'd get much advantage with this as the python global
> interpreter lock will block all threads while another is executing so
> you might as well run a single thread with all your tasklets in it?
Umm, yes. Having multiple OS threads to run multiple *pure Python*
tasklets each seems pretty much pointless.
> Unless ofcourse you have specific C routines in your code that get
> called into often that release the interpreter lock? Your best bet is
> probably to run some tests in your application and see which gives the
> best performance.
Or you use a blocking function from the Python library, or a function
from a third-party module, like a blocking database adapter.
All blocking functions, like sleep(), poll() or whatever will release
and reacquire the GIL (if threading is enabled - it normally is)
If you write C-Extensions, you need to call PyEval_InitThreads, and
bracket your blocking calls like:
...Do some blocking I/O operation...
Stackless mailing list
Stackless at stackless.com
More information about the Stackless