Author aeros
Recipients aeros, eric.snow, vstinner
Date 2019-09-20.05:03:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568955805.8.0.910770187463.issue37224@roundup.psfhosted.org>
In-reply-to
Content
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 (https://docs.python.org/3/c-api/init.html?highlight=global%20interpreter%20lock#bugs-and-caveats).

"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.
History
Date User Action Args
2019-09-20 05:03:25aerossetrecipients: + aeros, vstinner, eric.snow
2019-09-20 05:03:25aerossetmessageid: <1568955805.8.0.910770187463.issue37224@roundup.psfhosted.org>
2019-09-20 05:03:25aeroslinkissue37224 messages
2019-09-20 05:03:25aeroscreate