diff options
author | Yury Selivanov <yury@edgedb.com> | 2019-09-25 10:32:08 (GMT) |
---|---|---|
committer | Carol Willing <carolcode@willingconsulting.com> | 2019-09-25 10:32:08 (GMT) |
commit | edad4d89e357c92f70c0324b937845d652b20afd (patch) | |
tree | 98cea6eaaf38962883784942aba23160b009360f /Modules/_asynciomodule.c | |
parent | c64af8fad3c4f5751af624647fbb0ce023f525dc (diff) | |
download | cpython-edad4d89e357c92f70c0324b937845d652b20afd.zip cpython-edad4d89e357c92f70c0324b937845d652b20afd.tar.gz cpython-edad4d89e357c92f70c0324b937845d652b20afd.tar.bz2 |
bpo-38248: Fix inconsistent immediate asyncio.Task cancellation (GH-16330)
Diffstat (limited to 'Modules/_asynciomodule.c')
-rw-r--r-- | Modules/_asynciomodule.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 4d503a4..8ee0d7a 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -2628,18 +2628,19 @@ task_step_impl(TaskObj *task, PyObject *exc) if (_PyGen_FetchStopIterationValue(&o) == 0) { /* The error is StopIteration and that means that the underlying coroutine has resolved */ + + PyObject *res; if (task->task_must_cancel) { // Task is cancelled right before coro stops. - Py_DECREF(o); task->task_must_cancel = 0; - et = asyncio_CancelledError; - Py_INCREF(et); - ev = NULL; - tb = NULL; - goto set_exception; + res = future_cancel((FutureObj*)task); + } + else { + res = future_set_result((FutureObj*)task, o); } - PyObject *res = future_set_result((FutureObj*)task, o); + Py_DECREF(o); + if (res == NULL) { return NULL; } |