Skip to content

Commit

Permalink
Use variable
Browse files Browse the repository at this point in the history
  • Loading branch information
rruuaanng committed Oct 20, 2024
1 parent b947bc9 commit 46c2709
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2378,16 +2378,18 @@ PyEval_SetProfileAllThreads(Py_tracefunc func, PyObject *arg)
PyThreadState *this_tstate = _PyThreadState_GET();
PyInterpreterState *interp = this_tstate->interp;

HEAD_LOCK(&_PyRuntime);
_PyRuntimeState *runtime = &_PyRuntime;
HEAD_LOCK(runtime);
PyThreadState *ts = PyInterpreterState_ThreadHead(interp);
HEAD_UNLOCK(&_PyRuntime);
HEAD_UNLOCK(runtime);

while (ts) {
if (_PyEval_SetProfile(ts, func, arg) < 0) {
PyErr_FormatUnraisable("Exception ignored in PyEval_SetProfileAllThreads");
}
HEAD_LOCK(&_PyRuntime);
HEAD_LOCK(runtime);
ts = PyThreadState_Next(ts);
HEAD_UNLOCK(&_PyRuntime);
HEAD_UNLOCK(runtime);
}
}

Expand All @@ -2407,16 +2409,18 @@ PyEval_SetTraceAllThreads(Py_tracefunc func, PyObject *arg)
PyThreadState *this_tstate = _PyThreadState_GET();
PyInterpreterState *interp = this_tstate->interp;

HEAD_LOCK(&_PyRuntime);
_PyRuntimeState *runtime = &_PyRuntime;
HEAD_LOCK(runtime);
PyThreadState *ts = PyInterpreterState_ThreadHead(interp);
HEAD_UNLOCK(&_PyRuntime);
HEAD_UNLOCK(runtime);

while (ts) {
if (_PyEval_SetTrace(ts, func, arg) < 0) {
PyErr_FormatUnraisable("Exception ignored in PyEval_SetTraceAllThreads");
}
HEAD_LOCK(&_PyRuntime);
HEAD_LOCK(runtime);
ts = PyThreadState_Next(ts);
HEAD_UNLOCK(&_PyRuntime);
HEAD_UNLOCK(runtime);
}
}

Expand Down

0 comments on commit 46c2709

Please sign in to comment.