Visitar URL original
gh-104341: Ensure tstate Holding GIL is Always Current by ericsnowcurrently · Pull Request #104436 · python/cpython · GitHub
Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add _PyEval_HoldsLock().
  • Loading branch information
ericsnowcurrently committed May 11, 2023
commit 0cb1d0dccf91dd59e5e084f6c6c7145c4416854f
1 change: 1 addition & 0 deletions Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ extern void _PyEval_FiniGIL(PyInterpreterState *interp);

extern void _PyEval_AcquireLock(PyThreadState *tstate);
extern void _PyEval_ReleaseLock(PyThreadState *tstate);
extern int _PyEval_HoldsLock(PyThreadState *tstate);
extern PyThreadState * _PyThreadState_SwapNoGIL(PyThreadState *);

extern void _PyEval_DeactivateOpCache(void);
Expand Down
7 changes: 7 additions & 0 deletions Python/ceval_gil.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,13 @@ _PyEval_ReleaseLock(PyThreadState *tstate)
drop_gil(ceval, tstate);
}

int
_PyEval_HoldsLock(PyThreadState *tstate)
{
_Py_EnsureTstateNotNULL(tstate);
return current_thread_holds_gil(tstate->interp->ceval.gil, tstate);
}

void
PyEval_AcquireThread(PyThreadState *tstate)
{
Expand Down