[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-05-11 Thread INADA Naoki
Changes by INADA Naoki : -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python-bugs-li

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-05-11 Thread INADA Naoki
INADA Naoki added the comment: New changeset 5e94dedcddf5e09164bf20f18a3c701eeb96c71e by INADA Naoki in branch '3.5': bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1547) https://github.com/python/cpython/commit/5e94dedcddf5e09164bf20f18a3c701eeb96c71e --

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-05-11 Thread INADA Naoki
INADA Naoki added the comment: New changeset 3dc7c52a9f4fb83be3e26e31e2c7cd9dc1cb41a2 by INADA Naoki in branch '3.6': bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1546) https://github.com/python/cpython/commit/3dc7c52a9f4fb83be3e26e31e2c7cd9dc1cb41a2 --

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-05-11 Thread INADA Naoki
Changes by INADA Naoki : -- pull_requests: +1646 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-05-11 Thread INADA Naoki
Changes by INADA Naoki : -- pull_requests: +1645 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-05-11 Thread INADA Naoki
INADA Naoki added the comment: New changeset 991adca012f5e106c2d4040ce619c696ba6f9c46 by INADA Naoki in branch 'master': bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1097) https://github.com/python/cpython/commit/991adca012f5e106c2d4040ce619c696ba6f9c46 -- _

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread INADA Naoki
Changes by INADA Naoki : -- pull_requests: +1240 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread INADA Naoki
INADA Naoki added the comment: > In Evgeny's example the 'task' is 'coro1' (not 'coro2'). It has plenty of > yield points after being cancelled. Since coro1 waiting coro2 when cancelling, Task(coro1).cancel() redirect to Task(coro2).cancel(). But I was wrong about "CancelledError is thrown to

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread Yury Selivanov
Yury Selivanov added the comment: In Evgeny's example the 'task' is 'coro1' (not 'coro2'). It has plenty of yield points after being cancelled. -- ___ Python tracker ___ ___

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread INADA Naoki
INADA Naoki added the comment: > The problem is that the task doesn't catch CancelledError, yet it disappears. The problem is CancelledError is not raised, even it's thrown. Task can't catch exception not raised. See below example which demonstrates how task works. --- from asyncio import Can

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread Evgeny Kapun
Evgeny Kapun added the comment: The problem is that the task doesn't catch CancelledError, yet it disappears. -- ___ Python tracker ___ __

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread INADA Naoki
INADA Naoki added the comment: This behavior is documented as: https://docs.python.org/3.6/library/asyncio-task.html#asyncio.Task.cancel > Unlike Future.cancel(), this does not guarantee that the task will be > cancelled: the exception might be caught and acted upon, delaying > cancellation o

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-12 Thread INADA Naoki
INADA Naoki added the comment: When task.cancel() called, CancelledError is thrown to coro2. But coro2 doesn't call `yield from` after task.cancel(). So the exception is never raised. If you add `yield from` after `task.cancel()`, the script runs expected. --- $ cat at.py import asyncio as a @a

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-11 Thread Yury Selivanov
Yury Selivanov added the comment: Interesting. It doesn't work for both C and Python versions of the Task. I'll take a look in detail when I return from vacation. -- assignee: -> yselivanov nosy: +inada.naoki ___ Python tracker

[issue30048] If a task is canceled at the right moment, the cancellation is ignored

2017-04-11 Thread Evgeny Kapun
New submission from Evgeny Kapun: If I run this code: import asyncio as a @a.coroutine def coro1(): yield from a.ensure_future(coro2()) print("Still here") yield from a.sleep(1) print("Still here 2") @a.coroutine def coro2(): yield fr