]> granicus.if.org Git - python/commit
bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1547)
authorINADA Naoki <methane@users.noreply.github.com>
Fri, 12 May 2017 05:34:40 +0000 (14:34 +0900)
committerGitHub <noreply@github.com>
Fri, 12 May 2017 05:34:40 +0000 (14:34 +0900)
commit5e94dedcddf5e09164bf20f18a3c701eeb96c71e
treec8fddfb1e0c919ad26a4c4bb804d37eb066b3658
parentdab10f4f5b52c6de1aac3a8b5dc87d2eb0223a6c
bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1547)

* bpo-30048: asyncio: fix Task.cancel() was ignored. (GH-1097)

when there are no more `await` or `yield (from)` before return in coroutine,
cancel was ignored.

example:

    async def coro():
        asyncio.Task.current_task().cancel()
        return 42
    ...
    res = await coro()  # should raise CancelledError
(cherry picked from commit 991adca012f5e106c2d4040ce619c696ba6f9c46)

* fix test
Lib/asyncio/tasks.py
Lib/test/test_asyncio/test_tasks.py
Misc/NEWS