Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.064 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'resulting': 0.04; 'line:': 0.09; 'creates': 0.14; 'question.': 0.14; 'assigns': 0.16; 'cleaned': 0.16; 'set,': 0.16; 'task.': 0.16; 'tasks,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'print': 0.22; 'creating': 0.23; "shouldn't": 0.24; 'source': 0.25; 'references': 0.26; 'task': 0.26; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; 'up.': 0.33; 'fri,': 0.33; 'problem.': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'explains': 0.36; 'set.': 0.36; 'should': 0.36; 'list': 0.37; 'tasks': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'deleting': 0.60; 'solve': 0.60; 'back': 0.62; 'soon': 0.63; 'kept': 0.65; 'mar': 0.68; 'nobody': 0.68; 'tasks.': 0.68; '2015': 0.84; 'around,': 0.84; 'glance': 0.84; 'task,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=2mbwsKJj3y2OAyTqdjgmtVTyrtx9OtQY8wD8M1WT5U0=; b=wvMizmK6V3CiMqMea5ndT1lK1wQU/yxZ6rI+1jkdLhznVQvKU4r3hD7nioHWC4/dG/ 5Ag1HmASgP13DVFtsoITr0t7JHtqFAYubMh7fbtNIYNfKTcKXZqn7cfGIXglK0WR6sTN 9+cmuezGK7ij6aqk/u8bEGG9wW708WicOqskD9zLkiUO++yOpfVaa4MpE/bvJxJRph/+ uoiC8Ph+v2kSGgO8ceyeECr9xobXrtmaHzu9qC2v/O3TJF9sH/ufZT0BWggBOZL7t7UG z2w7ZaPJxRQve+kbFu3TRiNWuSJRQcBm3DlL88EI/1FFqOMITZPabGoNMvo3Q7xuPEh6 NX/A== X-Received: by 10.70.21.227 with SMTP id y3mr6374843pde.101.1427465795261; Fri, 27 Mar 2015 07:16:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <877fu2mx7x.fsf@elektro.pacujo.net> References: <87d23un7k2.fsf@elektro.pacujo.net> <877fu2mx7x.fsf@elektro.pacujo.net> From: Ian Kelly Date: Fri, 27 Mar 2015 08:15:54 -0600 Subject: Re: asyncio To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1427465798 news.xs4all.nl 2864 [2001:888:2000:d::a6]:53658 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88163 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.