Skip to content

Commit 6873433

Browse files
stop the world in all tasks
1 parent 8d15058 commit 6873433

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Include/internal/pycore_pystate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ extern void _PyEval_StartTheWorldAll(_PyRuntimeState *runtime);
182182
// Perform a stop-the-world pause for threads in the specified interpreter.
183183
//
184184
// NOTE: This is a no-op outside of Py_GIL_DISABLED builds.
185-
extern void _PyEval_StopTheWorld(PyInterpreterState *interp);
186-
extern void _PyEval_StartTheWorld(PyInterpreterState *interp);
185+
extern PyAPI_FUNC(void) _PyEval_StopTheWorld(PyInterpreterState *interp);
186+
extern PyAPI_FUNC(void) _PyEval_StartTheWorld(PyInterpreterState *interp);
187187

188188

189189
static inline void

Modules/_asynciomodule.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,9 +3767,11 @@ _asyncio_all_tasks_impl(PyObject *module, PyObject *loop)
37673767
return NULL;
37683768
}
37693769
int err = 0;
3770-
ASYNCIO_STATE_LOCK(state);
3771-
struct llist_node *node;
37723770

3771+
PyInterpreterState *interp = PyInterpreterState_Get();
3772+
_PyEval_StopTheWorld(interp);
3773+
3774+
struct llist_node *node;
37733775
llist_for_each_safe(node, &state->asyncio_tasks_head) {
37743776
TaskObj *task = llist_data(node, TaskObj, task_node);
37753777
if (PyList_Append(tasks, (PyObject *)task) < 0) {
@@ -3779,7 +3781,8 @@ _asyncio_all_tasks_impl(PyObject *module, PyObject *loop)
37793781
break;
37803782
}
37813783
}
3782-
ASYNCIO_STATE_UNLOCK(state);
3784+
3785+
_PyEval_StartTheWorld(interp);
37833786
if (err) {
37843787
return NULL;
37853788
}

0 commit comments

Comments
 (0)