Python threads question

Donn Cave donn at oz.net
Tue Aug 22 01:09:22 EDT 2000


Quoth "Makhno" <mak at imakhno.freeserve.co.uk>:
| <Py_BEGIN_ALLOW_THREADS>
|
|>| everytime I call a function in my extension. This way, the threads can
|>| continue working while the GUI is being manipulated (or just blocking for
|>| user input).
|>
|> Right, ...
|> 
|> Then if there are any external callbacks, such as for example
|> a function that might be called from a graphic interface dispatch
|> loop, before calling back into the interpreter you must acquire
|> the interpreter lock.
|
| And I re-acquire the interpreter lock (for the current thread) with
| Py_END_ALLOW_THREADS?

Yes, Py_BEGIN_ALLOW_THREADS before the external function call,
Py_END_ALLOW_THREADS after.  Usage examples can be found in several
standard modules, posixmodule.c, socketmodule.c et al.

For external callbacks, the only example that looks relevant to me
is _tkinter.c.  That may be more complex than your requirements.

	Donn Cave, donn at oz.net



More information about the Python-list mailing list