Message205004
The BaseSelectorEventLoop class (inherited by UnixSelectorEventLoop) creates a socketpair in its constructor. So if you don't call close(), the socketpair may stay alive.
It would be convinient to support the context manager to be able to write:
with asyncio.get_event_loop() as loop
# ... prepare loop ...
loop.run_forever()
# KeyboardInterrupt or SystemExit: loop.close() is called
Hello World examples don't call close(), so the sockets are not closed when the example is stopped using CTRL+c.
Attached patch adds __enter__/__exit__ methods to BaseEventLoop and use it in the two Hello World examples. |
|
Date |
User |
Action |
Args |
2013-12-02 11:45:59 | vstinner | set | recipients:
+ vstinner, gvanrossum, pitrou |
2013-12-02 11:45:59 | vstinner | set | messageid: <1385984759.42.0.47454056153.issue19860@psf.upfronthosting.co.za> |
2013-12-02 11:45:59 | vstinner | link | issue19860 messages |
2013-12-02 11:45:59 | vstinner | create | |
|