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.

Title: Expose HEAD_LOCK/HEAD_UNLOCK in pystate.c
Type: enhancement Stage:
Components: Versions:
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: fijall, vstinner
Priority: normal Keywords:

Created on 2016-07-11 16:50 by fijall, last changed 2022-04-11 14:58 by admin.

Messages (3)
msg270188 - (view) Author: Maciej Fijalkowski (fijall) * (Python committer) Date: 2016-07-11 16:50

The use case here is for C-based statistical profilers. When running vmprof on linux/os x, you can get the current thread state from PyThreadState_GetUnchecked or a similar solution. However, on windows you need to walk all the interpreter state, for which there is an API. However that API is only ever used with locks (HEAD_LOCK/HEAD_UNLOCK), which are not exposed, which turns API mostly useless.
msg270190 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2016-07-11 17:20
Is the profiler running in the same process than the profiled application?

Vmprof uses a signal handler, right? HEAD_LOCK is a mutex, acquire a mutex
is not async-signal safe :-( Is it an issue?
msg270192 - (view) Author: Maciej Fijalkowski (fijall) * (Python committer) Date: 2016-07-11 17:52
On windows the profiler runs in a separate thread and pauses/restarts other threads (hence the requirements are slightly different). HEAD_LOCK etc. are def not async-signal safe, but it's not an issue on linux
Date User Action Args
2022-04-11 14:58:33adminsetgithub: 71670
2016-07-11 17:52:09fijallsetmessages: + msg270192
2016-07-11 17:20:57vstinnersetmessages: + msg270190
2016-07-11 16:50:30fijallcreate