Asyncio tasks getting cancelled

Ian Kelly ian.g.kelly at gmail.com
Tue Nov 6 17:42:46 EST 2018


On Tue, Nov 6, 2018 at 3:39 PM Ian Kelly <ian.g.kelly at gmail.com> wrote:
>
> n Mon, Nov 5, 2018 at 8:43 PM <ike at koeln.ccc.de> wrote:
> > What I meant was, the error message is specific to futures in the
> > 'PENDING' state. Which should be set to 'RUNNING' before any actions
> > occur. So it appears the tasks weren't started at all.
>
> Ah. I don't think asyncio uses a RUNNING state. There's nothing about
> it in the docs; tasks are either done or they're not:
> https://docs.python.org/3/library/asyncio-task.html#task-object
>
> And inspecting the current task also shows PENDING:
>
> py> from asyncio import *
> py> async def main():
> ...   print(current_task()._state)
> ...
> py> run(main())
> PENDING

Looks like the only states are PENDING, CANCELLED, and FINISHED:
https://github.com/python/cpython/blob/3.7/Lib/asyncio/base_futures.py#L17



More information about the Python-list mailing list