Skip to content

Commit fa7c13e

Browse files
committed
Support coro_result in Task C impl
1 parent ac26ad6 commit fa7c13e

File tree

7 files changed

+31
-15
lines changed

7 files changed

+31
-15
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ struct _Py_global_strings {
337337
STRUCT_FOR_ID(copy)
338338
STRUCT_FOR_ID(copyreg)
339339
STRUCT_FOR_ID(coro)
340+
STRUCT_FOR_ID(coro_result)
340341
STRUCT_FOR_ID(count)
341342
STRUCT_FOR_ID(cwd)
342343
STRUCT_FOR_ID(d)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_asynciomodule.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,15 +2033,16 @@ _asyncio.Task.__init__
20332033
loop: object = None
20342034
name: object = None
20352035
context: object = None
2036+
coro_result: object = None
20362037
20372038
A coroutine wrapped in a Future.
20382039
[clinic start generated code]*/
20392040

20402041
static int
20412042
_asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
2042-
PyObject *name, PyObject *context)
2043-
/*[clinic end generated code: output=49ac96fe33d0e5c7 input=924522490c8ce825]*/
2044-
2043+
PyObject *name, PyObject *context,
2044+
PyObject *coro_result)
2045+
/*[clinic end generated code: output=e241855787412a77 input=56034b36df8d270d]*/
20452046
{
20462047
if (future_init((FutureObj*)self, loop)) {
20472048
return -1;
@@ -2089,8 +2090,10 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop,
20892090
return -1;
20902091
}
20912092

2092-
if (task_call_step_soon(state, self, NULL)) {
2093-
return -1;
2093+
if (!Py_IsNone(coro_result)) {
2094+
if (task_call_step_soon(state, self, NULL)) {
2095+
return -1;
2096+
}
20942097
}
20952098
return register_task(state, (PyObject*)self);
20962099
}

Modules/clinic/_asynciomodule.c.h

Lines changed: 17 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

async_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def counting_task_constructor(coro, *, loop=None, name=None, context=None, coro_
151151
# only count calls that will actually result a task scheduled to the event loop
152152
# (if coro_result is non-None, it will return synchronously)
153153
self.task_count += 1
154-
return asyncio.tasks._PyTask(coro, loop=loop, name=name, context=context, coro_result=coro_result)
154+
return asyncio.Task(coro, loop=loop, name=name, context=context, coro_result=coro_result)
155155

156156
def counting_task_factory(loop, coro, *, name=None, context=None, coro_result=None):
157157
return counting_task_constructor(coro, loop=loop, name=name, context=context, coro_result=coro_result)

0 commit comments

Comments
 (0)