Recipe request: asyncio "spin off coroutine"

Marko Rauhamaa marko at pacujo.net
Thu Dec 15 02:28:57 EST 2016


"Frank Millman" <frank at chagford.com>:

> "Marko Rauhamaa"  wrote in message news:87vaulitxe.fsf at elektro.pacujo.net...
>>
>> "Frank Millman" <frank at chagford.com>:
>>
>> > I changed 'await self.close()', to >
>> 'asyncio.ensure_future(self.close())'.
>> >
>> > Problem solved.
>>
>> A nice insight.
>>
>> However, shouldn't somebody somewhere in your code be keeping track of
>> the returned task?
>
> I don't know. What is the worst that could happen?

Only you can tell.

> I just assume that it will be executed at some point. Is it not
> reasonable to do the same here?

It ain't over till the fat lady sings. Things can accumulate, hang
and/or fail in surprising ways.

At the very least you should maintain statistics that reveal the number
of pending closing tasks for troubleshooting when things go south.


Marko


More information about the Python-list mailing list