asyncio
orangewarrior at gmail.com
orangewarrior at gmail.com
Fri Mar 27 19:27:44 EDT 2015
On Friday, March 27, 2015 at 7:17:26 AM UTC-7, Ian wrote:
> On Fri, Mar 27, 2015 at 6:38 AM, Marko Rauhamaa wrote:
> > 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.
>
> Actually I think this explains it. In the OP's while loop, he updates
> his task list with the line:
>
> tasks = asyncio.Task.all_tasks(loop)
>
> This creates a strong reference to each of the returned tasks. When
> the loop comes back around, it calls all_tasks again, creating a
> second strong reference to each task, then assigns the resulting set
> to tasks, allowing the original set to be collected. At no point in
> the loop is there ever not a strong reference to each task. So if
> asyncio is relying on GC to prune its task set, they will never be
> cleaned up.
>
> To the OP: try deleting the tasks variable after you print it out. I
> bet this will solve your problem.
I missed that part. Thanks!
More information about the Python-list
mailing list