Re: [python-tulip] closing event loops

2014-09-10 Thread Martin Teichmann
Hi again, thanks for all the great input! I still think there should still a warning in the documentation for BaseEventLoop.close that it does not cancel the tasks still running so that no finalizers are called. It is the last chance to do that in a controlled fashion, as the event loop cannot

Re: [python-tulip] closing event loops

2014-09-10 Thread Victor Stinner
Please, help me to enhance the documentation. Get the documentation source at: http://hg.python.org/cpython/file/5bc23c111de1/Doc/library/asyncio-eventloop.rst And send a patch. Victor 2014-09-10 13:04 GMT+02:00 Martin Teichmann martin.teichm...@gmail.com: Hi again, thanks for all the great

Re: [python-tulip] closing event loops

2014-09-09 Thread Martin Teichmann
Hi Guido, Hi List, for t in asyncio.Task.all_tasks(loop): t.cancel() loop.run_until_complete(asyncio.sleep(0.1)) # Give them a little time to recover loop.close() That solves my problem. Couln't we write def cancel(self): on top of it and put it into BaseEventLoop? In this case we

Re: [python-tulip] closing event loops

2014-09-09 Thread Guido van Rossum
On Tue, Sep 9, 2014 at 12:53 AM, Martin Teichmann martin.teichm...@gmail.com wrote: Hi Guido, Hi List, for t in asyncio.Task.all_tasks(loop): t.cancel() loop.run_until_complete(asyncio.sleep(0.1)) # Give them a little time to recover loop.close() That solves my problem. Couln't

Re: [python-tulip] closing event loops

2014-09-09 Thread Guido van Rossum
On Tue, Sep 9, 2014 at 11:12 AM, Martin Teichmann martin.teichm...@gmail.com wrote: Hi Guido, Hi List, And yet having a try/finally around a yield-from is an easy recipe for resisting cancellation -- it is all too convenient to put another yield-from in the finally clause, and then you are

[python-tulip] closing event loops

2014-09-08 Thread Martin Teichmann
Hi List, I use asyncio to start several tasks with asyncio.async. Several of them need to close some things before exiting, so I use a try...finally construction to do that. Unfortunately, the finalizers are never called. When running the event loop, I am using the same code as in several

Re: [python-tulip] closing event loops

2014-09-08 Thread Guido van Rossum
I can think of a variety of reasons where you don't want to bother with the tasks (possibly because they might resist being cancelled) but you still want to close the loop. In your finally clause you should be able to write something like this: for t in asyncio.Task.all_tasks(loop):