extension module, thread safety?
db3l at fitlinxx.com
Tue Jan 18 23:07:32 CET 2005
Nick Coghlan <ncoghlan at iinet.net.au> writes:
> Pierre Barbier de Reuille wrote:
> > Ok, I wondered why I didn't know these functions, but they are new
> > to Python 2.4 ( and I didn't take the time to look closely at Python
> > 2.4 as some modules I'm working with are still not available for
> > Python 2.4). But if it really allows to call Python code outside a
> > Python thread ... then I'll surely use that as soon as I can use
> > Python 2.4 :) Thanks for the hint :)
> The Python 2.4 docs claim the functions were added in Python 2.3, even
> though they aren't documented in the 2.3.4 docs.
> The 2.3 release PEP (PEP 283) confirms that PEP 311 (which added these
> functions) went in.
And even before that it was certainly possible to call into the Python
interpreter from a native thread using existing functions, albeit the
newer functions are more convenient (and perhaps more robust, I don't
My earliest interaction with Python (~1999, while writing a module
that extended and embedded Python 1.5.2) used PyEval_AcquireThread()
and PyEval_ReleaseThread() to get access to a thread state from a
native C application thread (not initiated by the Python interpreter)
to allow me to call safely into an executing Python script upon
asynchronous data reception by the C code.
More information about the Python-list