Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #88163

Re: asyncio

References <mailman.237.1427445210.10327.python-list@python.org> <87d23un7k2.fsf@elektro.pacujo.net> <b1431003-3cc6-4672-83b8-f82c4677d4b4@googlegroups.com> <877fu2mx7x.fsf@elektro.pacujo.net>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2015-03-27 08:15 -0600
Subject Re: asyncio
Newsgroups comp.lang.python
Message-ID <mailman.260.1427465798.10327.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Mar 27, 2015 at 6:38 AM, Marko Rauhamaa <marko@pacujo.net> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

asyncio Łukasz Ligowski <orangewarrior@gmail.com> - 2015-03-27 01:33 -0700
  Re: asyncio Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 10:55 +0200
    Re: asyncio orangewarrior@gmail.com - 2015-03-27 02:32 -0700
      Re: asyncio Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 14:38 +0200
        Re: asyncio Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-27 08:15 -0600
          Re: asyncio Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 17:44 +0200
            Re: asyncio Marko Rauhamaa <marko@pacujo.net> - 2015-03-27 17:52 +0200
          Re: asyncio orangewarrior@gmail.com - 2015-03-27 16:27 -0700

csiph-web