[Python-checkins] Fixed typo (GH-11522)

Miss Islington (bot) webhook-mailer at python.org
Fri May 3 11:25:43 EDT 2019


https://github.com/python/cpython/commit/ceb842e155f5fa0109fa88d52da3d1f5e73490ad
commit: ceb842e155f5fa0109fa88d52da3d1f5e73490ad
branch: master
author: Alexander Vasin <hi at alvass.in>
committer: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
date: 2019-05-03T08:25:36-07:00
summary:

Fixed typo (GH-11522)



Given example does not run, loop variable is missing.

Secondly, this is bad example how to handle shutdown signal, because it would cause `RuntimeError: Event loop stopped before Future completed.`

Perhaps it would be better to cancel all tasks instead of closing loop directly?

Did not create issue, because question is quite simple.

files:
M Doc/library/asyncio-eventloop.rst

diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index bf7c93a86fd0..e2b312453921 100644
--- a/Doc/library/asyncio-eventloop.rst
+++ b/Doc/library/asyncio-eventloop.rst
@@ -1601,7 +1601,7 @@ using the :meth:`loop.add_signal_handler` method::
     import os
     import signal
 
-    def ask_exit(signame):
+    def ask_exit(signame, loop):
         print("got signal %s: exit" % signame)
         loop.stop()
 
@@ -1611,7 +1611,7 @@ using the :meth:`loop.add_signal_handler` method::
         for signame in {'SIGINT', 'SIGTERM'}:
             loop.add_signal_handler(
                 getattr(signal, signame),
-                functools.partial(ask_exit, signame))
+                functools.partial(ask_exit, signame, loop))
 
         await asyncio.sleep(3600)
 



More information about the Python-checkins mailing list