Re: [python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-19 Thread Victor Stinner
2015-01-19 12:52 GMT+01:00 Luciano Ramalho luci...@ramalho.org: In a non-trivial program, how do I know mine was the first call to get_event_loop? It doesn't matter who called it first. You may even call close() more than once ;-) Just try to be kind, don't close the event loop if something

Re: [python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-19 Thread Luciano Ramalho
On Mon, Jan 19, 2015 at 12:02 PM, Victor Stinner victor.stin...@gmail.com wrote: 2015-01-19 12:52 GMT+01:00 Luciano Ramalho luci...@ramalho.org: In a non-trivial program, how do I know mine was the first call to get_event_loop? It doesn't matter who called it first. You may even call close()

Re: [python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-19 Thread Luciano Ramalho
On Mon, Jan 19, 2015 at 4:56 AM, Victor Stinner victor.stin...@gmail.com wrote: Event loops must be closed. The first call to get_event_loop() creates an event loop which must be closed when you are done. In a non-trivial program, how do I know mine was the first call to get_event_loop? Even a

Re: [python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-19 Thread Luciano Ramalho
In my previous message the crucial word NOT was missing from this sentence: Even a trivial program running in iPython Notebook under Qt will get an event loop that already existed, and that it should NOT close. Sorry... Best, Luciano On Mon, Jan 19, 2015 at 9:52 AM, Luciano Ramalho

Re: [python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-18 Thread Victor Stinner
Le lundi 19 janvier 2015, Luciano Ramalho luci...@ramalho.org a écrit : Can I conclude that in practice, close() should not be called at all unless your own code actually created the loop instead of merely fetching it with asyncio.get_event_loop()? Event loops must be closed. The first call

Re: [python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-18 Thread Guido van Rossum
Yes. It's a bit like memory allocation -- if you don't own it, don't free it. On Sun, Jan 18, 2015 at 3:41 PM, Luciano Ramalho luci...@ramalho.org wrote: Like Victor Stinner in this bug report [1], I was craving for a context-manager enabled loop so I did not forget to close() it. But

[python-tulip] Best practice for managing loop: don't close it (really!?)

2015-01-18 Thread Luciano Ramalho
Like Victor Stinner in this bug report [1], I was craving for a context-manager enabled loop so I did not forget to close() it. But reading Guido's last message rejecting that bug, it seems callign loop.close() is only recommended if you own the loop -- while most asyncio users probably don't own