Skip to content

Commit 7423dff

Browse files
committed
pystate: use stop-the-world in a few places
- _PyThread_CurrentExceptions - _PyThread_CurrentFrames
1 parent 82800d8 commit 7423dff

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Python/ceval.c

-4
Original file line numberDiff line numberDiff line change
@@ -2707,9 +2707,7 @@ PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *arg)
27072707

27082708
_PyObjectQueue *queue = NULL;
27092709

2710-
_PyMutex_lock(&_PyRuntime.stoptheworld_mutex);
27112710
_PyRuntimeState_StopTheWorld(&_PyRuntime);
2712-
27132711
HEAD_LOCK(runtime);
27142712
PyThreadState* ts = PyInterpreterState_ThreadHead(interp);
27152713
while (ts) {
@@ -2720,9 +2718,7 @@ PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *arg)
27202718
ts = PyThreadState_Next(ts);
27212719
}
27222720
HEAD_UNLOCK(runtime);
2723-
27242721
_PyRuntimeState_StartTheWorld(&_PyRuntime);
2725-
_PyMutex_unlock(&_PyRuntime.stoptheworld_mutex);
27262722

27272723
PyObject *old_traceobj;
27282724
_PyObjectQueue_ForEach(&queue, old_traceobj) {

Python/pystate.c

+4
Original file line numberDiff line numberDiff line change
@@ -1764,6 +1764,7 @@ _PyThread_CurrentFrames(void)
17641764
* need to grab head_mutex for the duration.
17651765
*/
17661766
_PyRuntimeState *runtime = tstate->interp->runtime;
1767+
_PyRuntimeState_StopTheWorld(runtime);
17671768
HEAD_LOCK(runtime);
17681769
PyInterpreterState *i;
17691770
for (i = runtime->interpreters.head; i != NULL; i = i->next) {
@@ -1797,6 +1798,7 @@ _PyThread_CurrentFrames(void)
17971798

17981799
done:
17991800
HEAD_UNLOCK(runtime);
1801+
_PyRuntimeState_StartTheWorld(runtime);
18001802
return result;
18011803
}
18021804

@@ -1823,6 +1825,7 @@ _PyThread_CurrentExceptions(void)
18231825
* need to grab head_mutex for the duration.
18241826
*/
18251827
_PyRuntimeState *runtime = tstate->interp->runtime;
1828+
_PyRuntimeState_StopTheWorld(runtime);
18261829
HEAD_LOCK(runtime);
18271830
PyInterpreterState *i;
18281831
for (i = runtime->interpreters.head; i != NULL; i = i->next) {
@@ -1856,6 +1859,7 @@ _PyThread_CurrentExceptions(void)
18561859

18571860
done:
18581861
HEAD_UNLOCK(runtime);
1862+
_PyRuntimeState_StartTheWorld(runtime);
18591863
return result;
18601864
}
18611865

0 commit comments

Comments
 (0)