Asyncio tasks getting cancelled
ike at koeln.ccc.de
ike at koeln.ccc.de
Wed Nov 21 18:13:06 EST 2018
Sorry for the latency.
On Tue, Nov 06, 2018 at 03:39:24PM -0700, Ian Kelly 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
Yes, you're right. I was confused and looked at futures, not
asyncio.futures. :/
> > Also the cleanup happens instantly, ie before the loop exits (as the
> > main loop has an asyncio.sleep timeout. Printing a message also clearly
> > shows this happens way before main returns.
>
> Okay, that wasn't clear from the log you posted. It's not obvious to
> me why that would be happening. although it does sound like the tasks
> are getting created and then immediately garbage-collected for some
> reason. It could be a bug in asyncio, or it could be a bug in the way
> the tasks are created, e.g. on a separate event loop that gets dropped
> on the floor.
Yes, I should have mentioned that earlier, sorry.
Hmm, I guess this will need some debugging incorporating the asyncio
module. Oh well, let's see if I come around to that.
Anyway thanks for the input.
More information about the Python-list
mailing list