summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Vasin <hi@alvass.in>2019-05-03 15:25:36 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-05-03 15:25:36 (GMT)
commitceb842e155f5fa0109fa88d52da3d1f5e73490ad (patch)
tree6d8cb2ebbac47022a878be49f2a7c782ce29a6f2
parentc1964e9e2177eabe821f3e4243be8b99e0d2d542 (diff)
downloadcpython-ceb842e155f5fa0109fa88d52da3d1f5e73490ad.zip
cpython-ceb842e155f5fa0109fa88d52da3d1f5e73490ad.tar.gz
cpython-ceb842e155f5fa0109fa88d52da3d1f5e73490ad.tar.bz2
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.
-rw-r--r--Doc/library/asyncio-eventloop.rst4
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst
index bf7c93a..e2b3124 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)