Is Python/C api thread safety enough?
Greg Ewing
greg at cosc.canterbury.ac.nz
Thu Nov 25 02:04:15 EST 2004
Donnie Leen wrote:
> If the long-running function comes from third-party library
> such as zlib.compress(), we don't know wether the function is
> safety for python thread, it may cause error, how could we
> avoid this if we have to use it?
A third-party library that knows nothing about Python
is unlikely to be making any Python/C API calls, so
you should be safe in that case.
If you pass a callback function to the library, and
your callback makes any Python/C API calls, it will
need to make sure it holds the GIL around those calls.
--
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg
More information about the Python-list
mailing list