Skip to content

Commit

Permalink
keep working
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 committed Dec 21, 2024
1 parent f3642ae commit 1f63b9e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Lib/test/test_asyncio/test_free_threading.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import sys
sys.modules["_asyncio"] = None

import asyncio
from test.support import threading_helper
from unittest import TestCase
Expand Down
10 changes: 7 additions & 3 deletions Modules/_asynciomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ future_set_result(asyncio_state *state, FutureObj *fut, PyObject *res)
if (future_ensure_alive(fut)) {
return NULL;
}
_Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED(fut);

if (fut->fut_state != STATE_PENDING) {
PyErr_SetString(state->asyncio_InvalidStateError, "invalid state");
Expand Down Expand Up @@ -3254,9 +3255,9 @@ task_step(asyncio_state *state, TaskObj *task, PyObject *exc)
if (enter_task(state, task->task_loop, (PyObject*)task) < 0) {
return NULL;
}

Py_BEGIN_CRITICAL_SECTION(task);
res = task_step_impl(state, task, exc);

Py_END_CRITICAL_SECTION();
if (res == NULL) {
PyObject *exc = PyErr_GetRaisedException();
leave_task(state, task->task_loop, (PyObject*)task);
Expand Down Expand Up @@ -3295,7 +3296,10 @@ task_eager_start(asyncio_state *state, TaskObj *task)

int retval = 0;

PyObject *stepres = task_step_impl(state, task, NULL);
PyObject *stepres;
Py_BEGIN_CRITICAL_SECTION(task);
stepres = task_step_impl(state, task, NULL);
Py_END_CRITICAL_SECTION();
if (stepres == NULL) {
PyObject *exc = PyErr_GetRaisedException();
_PyErr_ChainExceptions1(exc);
Expand Down

0 comments on commit 1f63b9e

Please sign in to comment.