This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aeros
Recipients aeros, eric.snow, vstinner
Date 2019-09-20.05:03:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Is there a currently reliable way of accessing the GIL functions within the sub-interpreters, without causing deadlock issues? I was trying to follow the advice in the documentation (

"It is highly recommended that you don’t switch sub-interpreters between a pair of matching PyGILState_Ensure() and PyGILState_Release() calls."

But it seemed that any attempt to use any of the PyGIL* calls within ``interp_destroy()`` in a meaningful way resulted in a deadlock, even if it was done away from the sub-interpreter switching.

My next idea would be to add a conditional check to see if the current thread has ownership of the GIL, and using ``PyEval_RestoreThread()`` to acquire it if it doesn't. This would be followed by releasing the GIL with ``PyThreadState_Get()`` at the end of the function. I'll try experimenting with that idea next.
Date User Action Args
2019-09-20 05:03:25aerossetrecipients: + aeros, vstinner, eric.snow
2019-09-20 05:03:25aerossetmessageid: <>
2019-09-20 05:03:25aeroslinkissue37224 messages
2019-09-20 05:03:25aeroscreate