summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-25 11:48:52 (GMT)
committerCarol Willing <carolcode@willingconsulting.com>2019-09-25 11:48:52 (GMT)
commit16cec136b75daf438080a5b6685d2679dfa406af (patch)
tree28585ccd5f98167c1a56377757dc71f7e2622559 /Modules
parent4633355a063c7bf068bdd72dfdd32f4c22cf382f (diff)
downloadcpython-16cec136b75daf438080a5b6685d2679dfa406af.zip
cpython-16cec136b75daf438080a5b6685d2679dfa406af.tar.gz
cpython-16cec136b75daf438080a5b6685d2679dfa406af.tar.bz2
bpo-38248: Fix inconsistent immediate asyncio.Task cancellation (GH-16330) (GH-16383)
(cherry picked from commit edad4d89e357c92f70c0324b937845d652b20afd) Co-authored-by: Yury Selivanov <yury@edgedb.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 281161b..cea3aff 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -2635,18 +2635,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;
}