gh-128002: fix many thread safety issues in asyncio (#128147)

* Makes `_asyncio.Task` and `_asyncio.Future` thread-safe by adding critical sections
* Add assertions to check for thread safety checking locking of object by critical sections in internal functions
* Make `_asyncio.all_tasks` thread safe when eager tasks are used
* Add a thread safety test
This commit is contained in:
Kumar Aditya 2025-01-04 14:18:22 +05:30 committed by GitHub
parent f1574859d7
commit 513a4efa75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 964 additions and 188 deletions

View file

@ -0,0 +1,82 @@
import asyncio
import unittest
from threading import Thread
from unittest import TestCase
from test.support import threading_helper
threading_helper.requires_working_threading(module=True)
def tearDownModule():
asyncio._set_event_loop_policy(None)
class TestFreeThreading:
def test_all_tasks_race(self) -> None:
async def main():
loop = asyncio.get_running_loop()
future = loop.create_future()
async def coro():
await future
tasks = set()
async with asyncio.TaskGroup() as tg:
for _ in range(100):
tasks.add(tg.create_task(coro()))
all_tasks = self.all_tasks(loop)
self.assertEqual(len(all_tasks), 101)
for task in all_tasks:
self.assertEqual(task.get_loop(), loop)
self.assertFalse(task.done())
current = self.current_task()
self.assertEqual(current.get_loop(), loop)
self.assertSetEqual(all_tasks, tasks | {current})
future.set_result(None)
def runner():
with asyncio.Runner() as runner:
loop = runner.get_loop()
loop.set_task_factory(self.factory)
runner.run(main())
threads = []
for _ in range(10):
thread = Thread(target=runner)
threads.append(thread)
with threading_helper.start_threads(threads):
pass
class TestPyFreeThreading(TestFreeThreading, TestCase):
all_tasks = staticmethod(asyncio.tasks._py_all_tasks)
current_task = staticmethod(asyncio.tasks._py_current_task)
def factory(self, loop, coro, context=None):
return asyncio.tasks._PyTask(coro, loop=loop, context=context)
@unittest.skipUnless(hasattr(asyncio.tasks, "_c_all_tasks"), "requires _asyncio")
class TestCFreeThreading(TestFreeThreading, TestCase):
all_tasks = staticmethod(getattr(asyncio.tasks, "_c_all_tasks", None))
current_task = staticmethod(getattr(asyncio.tasks, "_c_current_task", None))
def factory(self, loop, coro, context=None):
return asyncio.tasks._CTask(coro, loop=loop, context=context)
class TestEagerPyFreeThreading(TestPyFreeThreading):
def factory(self, loop, coro, context=None):
return asyncio.tasks._PyTask(coro, loop=loop, context=context, eager_start=True)
@unittest.skipUnless(hasattr(asyncio.tasks, "_c_all_tasks"), "requires _asyncio")
class TestEagerCFreeThreading(TestCFreeThreading, TestCase):
def factory(self, loop, coro, context=None):
return asyncio.tasks._CTask(coro, loop=loop, context=context, eager_start=True)

File diff suppressed because it is too large Load diff

View file

@ -6,6 +6,7 @@ preserve
# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
PyDoc_STRVAR(_asyncio_Future___init____doc__,
@ -98,7 +99,13 @@ _asyncio_Future_result_impl(FutureObj *self);
static PyObject *
_asyncio_Future_result(FutureObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Future_result_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_result_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Future_exception__doc__,
@ -121,11 +128,18 @@ _asyncio_Future_exception_impl(FutureObj *self, PyTypeObject *cls);
static PyObject *
_asyncio_Future_exception(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
PyErr_SetString(PyExc_TypeError, "exception() takes no arguments");
return NULL;
goto exit;
}
return _asyncio_Future_exception_impl(self, cls);
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_exception_impl(self, cls);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
}
PyDoc_STRVAR(_asyncio_Future_set_result__doc__,
@ -170,7 +184,9 @@ _asyncio_Future_set_result(FutureObj *self, PyTypeObject *cls, PyObject *const *
goto exit;
}
result = args[0];
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_set_result_impl(self, cls, result);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
@ -218,7 +234,9 @@ _asyncio_Future_set_exception(FutureObj *self, PyTypeObject *cls, PyObject *cons
goto exit;
}
exception = args[0];
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_set_exception_impl(self, cls, exception);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
@ -286,7 +304,9 @@ _asyncio_Future_add_done_callback(FutureObj *self, PyTypeObject *cls, PyObject *
}
context = args[1];
skip_optional_kwonly:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_add_done_callback_impl(self, cls, fn, context);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
@ -333,7 +353,9 @@ _asyncio_Future_remove_done_callback(FutureObj *self, PyTypeObject *cls, PyObjec
goto exit;
}
fn = args[0];
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_remove_done_callback_impl(self, cls, fn);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
@ -399,7 +421,9 @@ _asyncio_Future_cancel(FutureObj *self, PyTypeObject *cls, PyObject *const *args
}
msg = args[0];
skip_optional_pos:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_cancel_impl(self, cls, msg);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
@ -420,7 +444,13 @@ _asyncio_Future_cancelled_impl(FutureObj *self);
static PyObject *
_asyncio_Future_cancelled(FutureObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Future_cancelled_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_cancelled_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Future_done__doc__,
@ -441,7 +471,13 @@ _asyncio_Future_done_impl(FutureObj *self);
static PyObject *
_asyncio_Future_done(FutureObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Future_done_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_done_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Future_get_loop__doc__,
@ -459,11 +495,319 @@ _asyncio_Future_get_loop_impl(FutureObj *self, PyTypeObject *cls);
static PyObject *
_asyncio_Future_get_loop(FutureObj *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) {
PyErr_SetString(PyExc_TypeError, "get_loop() takes no arguments");
return NULL;
goto exit;
}
return _asyncio_Future_get_loop_impl(self, cls);
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future_get_loop_impl(self, cls);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
}
#if !defined(_asyncio_Future__asyncio_future_blocking_DOCSTR)
# define _asyncio_Future__asyncio_future_blocking_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF)
# undef _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF
# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, _asyncio_Future__asyncio_future_blocking_DOCSTR},
#else
# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, NULL, _asyncio_Future__asyncio_future_blocking_DOCSTR},
#endif
static PyObject *
_asyncio_Future__asyncio_future_blocking_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__asyncio_future_blocking_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__asyncio_future_blocking_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__asyncio_future_blocking_DOCSTR)
# define _asyncio_Future__asyncio_future_blocking_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF)
# undef _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF
# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", (getter)_asyncio_Future__asyncio_future_blocking_get, (setter)_asyncio_Future__asyncio_future_blocking_set, _asyncio_Future__asyncio_future_blocking_DOCSTR},
#else
# define _ASYNCIO_FUTURE__ASYNCIO_FUTURE_BLOCKING_GETSETDEF {"_asyncio_future_blocking", NULL, (setter)_asyncio_Future__asyncio_future_blocking_set, NULL},
#endif
static int
_asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self,
PyObject *value);
static int
_asyncio_Future__asyncio_future_blocking_set(FutureObj *self, PyObject *value, void *Py_UNUSED(context))
{
int return_value;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__asyncio_future_blocking_set_impl(self, value);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__log_traceback_DOCSTR)
# define _asyncio_Future__log_traceback_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF)
# undef _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF
# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, _asyncio_Future__log_traceback_DOCSTR},
#else
# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, NULL, _asyncio_Future__log_traceback_DOCSTR},
#endif
static PyObject *
_asyncio_Future__log_traceback_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__log_traceback_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__log_traceback_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__log_traceback_DOCSTR)
# define _asyncio_Future__log_traceback_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF)
# undef _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF
# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", (getter)_asyncio_Future__log_traceback_get, (setter)_asyncio_Future__log_traceback_set, _asyncio_Future__log_traceback_DOCSTR},
#else
# define _ASYNCIO_FUTURE__LOG_TRACEBACK_GETSETDEF {"_log_traceback", NULL, (setter)_asyncio_Future__log_traceback_set, NULL},
#endif
static int
_asyncio_Future__log_traceback_set_impl(FutureObj *self, PyObject *value);
static int
_asyncio_Future__log_traceback_set(FutureObj *self, PyObject *value, void *Py_UNUSED(context))
{
int return_value;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__log_traceback_set_impl(self, value);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__loop_DOCSTR)
# define _asyncio_Future__loop_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__LOOP_GETSETDEF)
# undef _ASYNCIO_FUTURE__LOOP_GETSETDEF
# define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, (setter)_asyncio_Future__loop_set, _asyncio_Future__loop_DOCSTR},
#else
# define _ASYNCIO_FUTURE__LOOP_GETSETDEF {"_loop", (getter)_asyncio_Future__loop_get, NULL, _asyncio_Future__loop_DOCSTR},
#endif
static PyObject *
_asyncio_Future__loop_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__loop_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__loop_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__callbacks_DOCSTR)
# define _asyncio_Future__callbacks_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__CALLBACKS_GETSETDEF)
# undef _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF
# define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, (setter)_asyncio_Future__callbacks_set, _asyncio_Future__callbacks_DOCSTR},
#else
# define _ASYNCIO_FUTURE__CALLBACKS_GETSETDEF {"_callbacks", (getter)_asyncio_Future__callbacks_get, NULL, _asyncio_Future__callbacks_DOCSTR},
#endif
static PyObject *
_asyncio_Future__callbacks_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__callbacks_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__callbacks_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__result_DOCSTR)
# define _asyncio_Future__result_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__RESULT_GETSETDEF)
# undef _ASYNCIO_FUTURE__RESULT_GETSETDEF
# define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, (setter)_asyncio_Future__result_set, _asyncio_Future__result_DOCSTR},
#else
# define _ASYNCIO_FUTURE__RESULT_GETSETDEF {"_result", (getter)_asyncio_Future__result_get, NULL, _asyncio_Future__result_DOCSTR},
#endif
static PyObject *
_asyncio_Future__result_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__result_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__result_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__exception_DOCSTR)
# define _asyncio_Future__exception_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__EXCEPTION_GETSETDEF)
# undef _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF
# define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, (setter)_asyncio_Future__exception_set, _asyncio_Future__exception_DOCSTR},
#else
# define _ASYNCIO_FUTURE__EXCEPTION_GETSETDEF {"_exception", (getter)_asyncio_Future__exception_get, NULL, _asyncio_Future__exception_DOCSTR},
#endif
static PyObject *
_asyncio_Future__exception_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__exception_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__exception_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__source_traceback_DOCSTR)
# define _asyncio_Future__source_traceback_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF)
# undef _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF
# define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, (setter)_asyncio_Future__source_traceback_set, _asyncio_Future__source_traceback_DOCSTR},
#else
# define _ASYNCIO_FUTURE__SOURCE_TRACEBACK_GETSETDEF {"_source_traceback", (getter)_asyncio_Future__source_traceback_get, NULL, _asyncio_Future__source_traceback_DOCSTR},
#endif
static PyObject *
_asyncio_Future__source_traceback_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__source_traceback_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__source_traceback_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__cancel_message_DOCSTR)
# define _asyncio_Future__cancel_message_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF)
# undef _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF
# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, _asyncio_Future__cancel_message_DOCSTR},
#else
# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, NULL, _asyncio_Future__cancel_message_DOCSTR},
#endif
static PyObject *
_asyncio_Future__cancel_message_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__cancel_message_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__cancel_message_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__cancel_message_DOCSTR)
# define _asyncio_Future__cancel_message_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF)
# undef _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF
# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", (getter)_asyncio_Future__cancel_message_get, (setter)_asyncio_Future__cancel_message_set, _asyncio_Future__cancel_message_DOCSTR},
#else
# define _ASYNCIO_FUTURE__CANCEL_MESSAGE_GETSETDEF {"_cancel_message", NULL, (setter)_asyncio_Future__cancel_message_set, NULL},
#endif
static int
_asyncio_Future__cancel_message_set_impl(FutureObj *self, PyObject *value);
static int
_asyncio_Future__cancel_message_set(FutureObj *self, PyObject *value, void *Py_UNUSED(context))
{
int return_value;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__cancel_message_set_impl(self, value);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Future__state_DOCSTR)
# define _asyncio_Future__state_DOCSTR NULL
#endif
#if defined(_ASYNCIO_FUTURE__STATE_GETSETDEF)
# undef _ASYNCIO_FUTURE__STATE_GETSETDEF
# define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, (setter)_asyncio_Future__state_set, _asyncio_Future__state_DOCSTR},
#else
# define _ASYNCIO_FUTURE__STATE_GETSETDEF {"_state", (getter)_asyncio_Future__state_get, NULL, _asyncio_Future__state_DOCSTR},
#endif
static PyObject *
_asyncio_Future__state_get_impl(FutureObj *self);
static PyObject *
_asyncio_Future__state_get(FutureObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__state_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Future__make_cancelled_error__doc__,
@ -484,7 +828,13 @@ _asyncio_Future__make_cancelled_error_impl(FutureObj *self);
static PyObject *
_asyncio_Future__make_cancelled_error(FutureObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Future__make_cancelled_error_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Future__make_cancelled_error_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task___init____doc__,
@ -575,6 +925,131 @@ exit:
return return_value;
}
#if !defined(_asyncio_Task__log_destroy_pending_DOCSTR)
# define _asyncio_Task__log_destroy_pending_DOCSTR NULL
#endif
#if defined(_ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF)
# undef _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF
# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, _asyncio_Task__log_destroy_pending_DOCSTR},
#else
# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, NULL, _asyncio_Task__log_destroy_pending_DOCSTR},
#endif
static PyObject *
_asyncio_Task__log_destroy_pending_get_impl(TaskObj *self);
static PyObject *
_asyncio_Task__log_destroy_pending_get(TaskObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task__log_destroy_pending_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Task__log_destroy_pending_DOCSTR)
# define _asyncio_Task__log_destroy_pending_DOCSTR NULL
#endif
#if defined(_ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF)
# undef _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF
# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", (getter)_asyncio_Task__log_destroy_pending_get, (setter)_asyncio_Task__log_destroy_pending_set, _asyncio_Task__log_destroy_pending_DOCSTR},
#else
# define _ASYNCIO_TASK__LOG_DESTROY_PENDING_GETSETDEF {"_log_destroy_pending", NULL, (setter)_asyncio_Task__log_destroy_pending_set, NULL},
#endif
static int
_asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, PyObject *value);
static int
_asyncio_Task__log_destroy_pending_set(TaskObj *self, PyObject *value, void *Py_UNUSED(context))
{
int return_value;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task__log_destroy_pending_set_impl(self, value);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Task__must_cancel_DOCSTR)
# define _asyncio_Task__must_cancel_DOCSTR NULL
#endif
#if defined(_ASYNCIO_TASK__MUST_CANCEL_GETSETDEF)
# undef _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF
# define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, (setter)_asyncio_Task__must_cancel_set, _asyncio_Task__must_cancel_DOCSTR},
#else
# define _ASYNCIO_TASK__MUST_CANCEL_GETSETDEF {"_must_cancel", (getter)_asyncio_Task__must_cancel_get, NULL, _asyncio_Task__must_cancel_DOCSTR},
#endif
static PyObject *
_asyncio_Task__must_cancel_get_impl(TaskObj *self);
static PyObject *
_asyncio_Task__must_cancel_get(TaskObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task__must_cancel_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Task__coro_DOCSTR)
# define _asyncio_Task__coro_DOCSTR NULL
#endif
#if defined(_ASYNCIO_TASK__CORO_GETSETDEF)
# undef _ASYNCIO_TASK__CORO_GETSETDEF
# define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, (setter)_asyncio_Task__coro_set, _asyncio_Task__coro_DOCSTR},
#else
# define _ASYNCIO_TASK__CORO_GETSETDEF {"_coro", (getter)_asyncio_Task__coro_get, NULL, _asyncio_Task__coro_DOCSTR},
#endif
static PyObject *
_asyncio_Task__coro_get_impl(TaskObj *self);
static PyObject *
_asyncio_Task__coro_get(TaskObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task__coro_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
#if !defined(_asyncio_Task__fut_waiter_DOCSTR)
# define _asyncio_Task__fut_waiter_DOCSTR NULL
#endif
#if defined(_ASYNCIO_TASK__FUT_WAITER_GETSETDEF)
# undef _ASYNCIO_TASK__FUT_WAITER_GETSETDEF
# define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, (setter)_asyncio_Task__fut_waiter_set, _asyncio_Task__fut_waiter_DOCSTR},
#else
# define _ASYNCIO_TASK__FUT_WAITER_GETSETDEF {"_fut_waiter", (getter)_asyncio_Task__fut_waiter_get, NULL, _asyncio_Task__fut_waiter_DOCSTR},
#endif
static PyObject *
_asyncio_Task__fut_waiter_get_impl(TaskObj *self);
static PyObject *
_asyncio_Task__fut_waiter_get(TaskObj *self, void *Py_UNUSED(context))
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task__fut_waiter_get_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task__make_cancelled_error__doc__,
"_make_cancelled_error($self, /)\n"
"--\n"
@ -593,7 +1068,13 @@ _asyncio_Task__make_cancelled_error_impl(TaskObj *self);
static PyObject *
_asyncio_Task__make_cancelled_error(TaskObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Task__make_cancelled_error_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task__make_cancelled_error_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task_cancel__doc__,
@ -670,7 +1151,9 @@ _asyncio_Task_cancel(TaskObj *self, PyObject *const *args, Py_ssize_t nargs, PyO
}
msg = args[0];
skip_optional_pos:
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task_cancel_impl(self, msg);
Py_END_CRITICAL_SECTION();
exit:
return return_value;
@ -694,7 +1177,13 @@ _asyncio_Task_cancelling_impl(TaskObj *self);
static PyObject *
_asyncio_Task_cancelling(TaskObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Task_cancelling_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task_cancelling_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task_uncancel__doc__,
@ -717,7 +1206,13 @@ _asyncio_Task_uncancel_impl(TaskObj *self);
static PyObject *
_asyncio_Task_uncancel(TaskObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Task_uncancel_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task_uncancel_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task_get_stack__doc__,
@ -905,7 +1400,13 @@ _asyncio_Task_get_coro_impl(TaskObj *self);
static PyObject *
_asyncio_Task_get_coro(TaskObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Task_get_coro_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task_get_coro_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task_get_context__doc__,
@ -939,7 +1440,13 @@ _asyncio_Task_get_name_impl(TaskObj *self);
static PyObject *
_asyncio_Task_get_name(TaskObj *self, PyObject *Py_UNUSED(ignored))
{
return _asyncio_Task_get_name_impl(self);
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task_get_name_impl(self);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio_Task_set_name__doc__,
@ -950,6 +1457,21 @@ PyDoc_STRVAR(_asyncio_Task_set_name__doc__,
#define _ASYNCIO_TASK_SET_NAME_METHODDEF \
{"set_name", (PyCFunction)_asyncio_Task_set_name, METH_O, _asyncio_Task_set_name__doc__},
static PyObject *
_asyncio_Task_set_name_impl(TaskObj *self, PyObject *value);
static PyObject *
_asyncio_Task_set_name(TaskObj *self, PyObject *value)
{
PyObject *return_value = NULL;
Py_BEGIN_CRITICAL_SECTION(self);
return_value = _asyncio_Task_set_name_impl(self, value);
Py_END_CRITICAL_SECTION();
return return_value;
}
PyDoc_STRVAR(_asyncio__get_running_loop__doc__,
"_get_running_loop($module, /)\n"
"--\n"
@ -1566,4 +2088,4 @@ skip_optional_pos:
exit:
return return_value;
}
/*[clinic end generated code: output=e5d95a0ec229ffcd input=a9049054013a1b77]*/
/*[clinic end generated code: output=408e156476ced07f input=a9049054013a1b77]*/