Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88141
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <orangewarrior@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.060 |
| X-Spam-Evidence | '*H*': 0.88; '*S*': 0.00; 'below)': 0.09; 'forcing': 0.09; 'ping': 0.09; 'python': 0.11; 'def': 0.12; 'wrote': 0.14; 'true:': 0.16; 'finished': 0.19; 'import': 0.22; '(by': 0.24; 'skip:l 30': 0.24; 'question': 0.24; '(see': 0.26; 'task': 0.26; 'defined': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'correctly.': 0.31; 'prints': 0.31; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; '8bit%:9': 0.36; 'done,': 0.36; 'yield': 0.36; 'hi,': 0.36; 'skip:& 10': 0.38; 'tasks': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'new': 0.61; 'from:charset:utf-8': 0.61; 'simple': 0.61; '8bit%:10': 0.64; 'of:': 0.68; 'behavior': 0.77; 'launches': 0.84; 'increases': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=s8mPicURz/ONAWOBlqXs3hh1GX/3t2YUnBRF9siTI1s=; b=UDS+1IsgyGAvgxDinhYjuLhSrXxdHG+FeGwszGQaRGSsd0YXK2d/VIaCBwJ00R+/+8 /b+8XOrAAUa90gPVrQZSmszQKZ3Lv4HXVrbsep3NX0Oo2R6GHX8F5UrA1tLl3y2A/7nS p4AN/jwPyPhJwRV89bKLyXSel03RfbujhH0d6T21vh9y4pdP8mP6agdv+ypkLQhNv0Zr DNJK/oFm93RNyQMnKDE6aVK6hMYTiutf3V9AX/U7gyv0EIXzuRyQVI+YtaB5e+tVJXL/ 9zNrvmOTUs0PvZxBx91JuLQ9yRFL3daCszMwmJxPlIIwKvNv9MAAp0VG7vSdOqdpnpjp n4tw== |
| MIME-Version | 1.0 |
| X-Received | by 10.202.3.65 with SMTP id 62mr14461915oid.11.1427445207414; Fri, 27 Mar 2015 01:33:27 -0700 (PDT) |
| Date | Fri, 27 Mar 2015 01:33:27 -0700 |
| Subject | asyncio |
| From | Łukasz Ligowski <orangewarrior@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/alternative; boundary=001a113ba080863eb9051240fc71 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.19 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.237.1427445210.10327.python-list@python.org> (permalink) |
| Lines | 96 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1427445210 news.xs4all.nl 2852 [2001:888:2000:d::a6]:40383 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:88141 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
Hi,
I wrote simple asyncio program (see below) and I'm not sure if I understand
behavior correctly.
I have print_tasks coroutine which prints each task in a loop by using
Task.all_tasks function.
I have also task_launcher coroutine that launches (by loop.create_task())
simple task that waits some and prints "ping".
Question is why finished "ping" tasks keep accumulating in Task.all_tasks?
After a while there is a lot of:
<Task finished coro=<ping() done, defined at test.py:25> result=None>
when printing in Task.all_tasks and number of those increases as new ping
tasks are launched
Is there a way to prune finished tasks (I tried forcing gc) or I do
something wrong?
I ran on python 3.4.3.
Best regards,
L
import asyncio
loop = asyncio.get_event_loop()
@asyncio.coroutine
def print_tasks(loop):
while True:
tasks = asyncio.Task.all_tasks(loop)
for task in tasks:
print(task)
print()
yield from asyncio.sleep(1)
@asyncio.coroutine
def task_launcher(loop):
while True:
yield from asyncio.sleep(1)
loop.create_task(ping())
@asyncio.coroutine
def ping():
yield from asyncio.sleep(2)
print("ping")
loop.create_task(print_tasks(loop))
loop.create_task(task_launcher(loop))
loop.run_forever()
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll 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