asyncio

Marko Rauhamaa marko at pacujo.net
Fri Mar 27 08:38:42 EDT 2015


orangewarrior at gmail.com:

> On Friday, March 27, 2015 at 1:55:36 AM UTC-7, Marko Rauhamaa wrote:
>> Łukasz Ligowski <orangewarrior at gmail.com>:
>> 
>> > Is there a way to prune finished tasks (I tried forcing gc) or I do
>> > something wrong?
>> 
>> Guessing that you need to call asyncio.wait() or asyncio.wait_for() to
>> get rid of the zombies.
>> 
>> (Apparently the loop object keeps references to completed tasks. I'm not
>> sure this design choice is necessary.)
>
> Should I launch tasks differently? Waiting for task that is done returns
> that task in done subset but it still lingers in list of all tasks...

I don't know the answer to your question. A superficial glance at the
relevant asyncio source code (and documentation) suggests you shouldn't
be seeing what you are seeing.

Tasks are kept in a weak set. Tasks should evaporate as soon as nobody
references them.

I wonder if there's a cyclical reference there somewhere. See if running
GC removes the tasks.


Marko



More information about the Python-list mailing list