C-extension not threadable?

Martin v. Loewis martin at v.loewis.de
Tue Apr 16 14:58:59 EDT 2002


stojek at part-gmbh.de (Marcus Stojek) writes:

> The C-extension does what it is supposed to do, the callback function
> works, but the C-function does not start as a parallel thread but is
> freezing my UI. Anything basic I miss here ?

Yes, the Global Interpreter Lock (GIL). When C code runs that was
invoked from Python code, it holds the GIL, and only one such C code
can run at any time. So you need to release the lock, using
Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS.

Regards,
Martin




More information about the Python-list mailing list