[Numpy-discussion] minor threads-related issue in numpy-release 1.6.2 and numpy-dev

Aron Ahmadia aron at ahmadia.net
Tue Aug 14 09:47:48 EDT 2012

Hi all,

Installing numpy 1.6.2 against a Python interpreter built with the
--without threads currently fails due to missing references
to PyGILState_Ensure and PyGILState_Release.  The references appear to be
coming from the following code in nditer.c.src:

NpyIter_DebugPrint(NpyIter *iter)
// <snip>
    PyGILState_STATE gilstate = PyGILState_Ensure();
// <snip>

Since this is debugging code, I'm guessing it doesn't get called very
frequently, and I could probably just #ifdef it out or use the NPY macros
for grabbing the GIL for a non-threaded build: (NPY_ALLOW_C_API
and NPY_DISABLE_C_API), but I don't understand why it's grabbing the GIL in
the first place.  Where is it calling into the interpreter?  Does it need
the GIL for something else?  I'm hesitant to touch this code and issue a
pull request until I understand what it's trying to do.

Heading on over to the master branch at numpy/numpy, I'm starting to notice
more unprotected PyGILState references creeping into the development code.
 Even the Python developers seem to think that nobody is using
--without-threaded, so I'm not going to make a strong case for being more
careful, but I do want to point it out in case you want to keep the numpy
sources correct for this case.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120814/213dde30/attachment.html>

More information about the NumPy-Discussion mailing list