diff options
author | Guido van Rossum <guido@python.org> | 2022-02-28 23:15:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 23:15:56 (GMT) |
commit | 7d611b4cabaf7925f5f94daddf711d54aeae2cf9 (patch) | |
tree | 4c8a48847d780e1a2632a15d8ae2b551bc224ad8 /Modules | |
parent | 08deed1af56bec8668c6cb4d5cfd89e393e1fe5e (diff) | |
download | cpython-7d611b4cabaf7925f5f94daddf711d54aeae2cf9.zip cpython-7d611b4cabaf7925f5f94daddf711d54aeae2cf9.tar.gz cpython-7d611b4cabaf7925f5f94daddf711d54aeae2cf9.tar.bz2 |
bpo-46771: Remove two controversial lines from Task.cancel() (GH-31623)
Also from the _asyncio C accelerator module,
and adjust one test that the change caused to fail.
For more discussion see the discussion starting here:
https://github.com/python/cpython/pull/31394#issuecomment-1053545331
(Basically, @asvetlov proposed to return False from cancel()
when there is already a pending cancellation, and I went along,
even though it wasn't necessary for the task group implementation,
and @agronholm has come up with a counterexample that fails
because of this change. So now I'm changing it back to the old
semantics (but still bumping the counter) until we can have a
proper discussion about this.)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_asynciomodule.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c index 8847123..2a6c0b3 100644 --- a/Modules/_asynciomodule.c +++ b/Modules/_asynciomodule.c @@ -2206,9 +2206,13 @@ _asyncio_Task_cancel_impl(TaskObj *self, PyObject *msg) } self->task_num_cancels_requested += 1; - if (self->task_num_cancels_requested > 1) { - Py_RETURN_FALSE; - } + + // These three lines are controversial. See discussion starting at + // https://github.com/python/cpython/pull/31394#issuecomment-1053545331 + // and corresponding code in tasks.py. + // if (self->task_num_cancels_requested > 1) { + // Py_RETURN_FALSE; + // } if (self->task_fut_waiter) { PyObject *res; |