This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Example in asyncio event throws resource usage warning
Type: resource usage Stage: resolved
Components: asyncio, Documentation Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, gvanrossum, python-dev, vajrasky, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2014-07-05 08:45 by vajrasky, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
close_loop_on_example.patch vajrasky, 2014-07-05 08:45 review
Messages (3)
msg222344 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2014-07-05 08:45
These examples coming from:
https://docs.python.org/3/library/asyncio-eventloop.html#example-hello-world-callback

and

https://docs.python.org/3/library/asyncio-eventloop.html#example-set-signal-handlers-for-sigint-and-sigterm

throw resource usage warning.

One of them gives this output:
Event loop running forever, press CTRL+c to interrupt.
pid 3075: send SIGINT or SIGTERM to exit.
^Cgot signal SIGINT: exit
sys:1: ResourceWarning: unclosed <socket object at 0x7f7124783448>
sys:1: ResourceWarning: unclosed <socket object at 0x7f7124c230e8>

The patch adds closing the loop code in the examples.
msg222362 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-07-05 13:41
New changeset f6827c6b1164 by Victor Stinner in branch '3.4':
Closes #21921: Fix ResourceWarning in the asyncio examples: close the event
http://hg.python.org/cpython/rev/f6827c6b1164

New changeset 0533f148fb49 by Victor Stinner in branch 'default':
(Merge 3.4) Closes #21921: Fix ResourceWarning in the asyncio examples: close
http://hg.python.org/cpython/rev/0533f148fb49
msg222363 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-07-05 13:43
Thanks for the fix. I already suggested it to Guido van Rossum a few months ago, but he preferred the keep the example simple. I made the same fix in the 2 hello world examples of the Tulip project last Tuesday, so it's fair to apply the same fix to asyncio examples.

Thanks for the fix Vajrasky.
History
Date User Action Args
2022-04-11 14:58:05adminsetgithub: 66120
2014-07-05 13:43:20vstinnersetmessages: + msg222363
2014-07-05 13:41:28python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg222362

resolution: fixed
stage: resolved
2014-07-05 08:45:13vajraskycreate