[pypy-issue] [issue1175] PyThread_{get, set, delete}_key_value should work without the GIL held

Marien Zwart tracker at bugs.pypy.org
Fri Jun 29 17:23:16 CEST 2012

Marien Zwart <marien.zwart at gmail.com> added the comment:

The attached patch fixes this, although it's not entirely right.

It removes pypy/module/cpyext/thread.py, adding the functions defined in it to
pypy/module/cpyext/src/thread.c (and their declarations to pythread.h, like they
are in cpython). The tests of the converted functions were similarly converted.
This means the cpyext thread.c now needs to include thread.h from
pypy/translator/c. An include path was added when building the cpyext source to
make this possible.

The problem I ran into is that including thread.h without PYPY_NOT_MAIN_FILE
defined defines several threading-related functions. I had to add a #define for
this to thread.c to prevent duplicate definitions when creating pypy-c. I think
that part is actually correct, as a few other .c files have this define,
presumably for similar reasons. But for some reason the cpyext tests end up with
no definition of the threading-related functions, causing them to fail. I hacked
around that by adding an include of src/thread.h to build_bridge, but although
this gives me a working pypy-c and passing cpyext tests it is almost certainly
not sane. I do not know what the correct fix for this is: adding that include to
a more sensible location or somehow including some of ll_thread when building
cpyext, assuming a reference to ll_thread is what previously got these functions

status: unread -> chatting

PyPy bug tracker <tracker at bugs.pypy.org>

More information about the pypy-issue mailing list