Commit ceb842e1 authored by Alexander Vasin's avatar Alexander Vasin Committed by Miss Islington (bot)

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.
parent c1964e9e
...@@ -1601,7 +1601,7 @@ using the :meth:`loop.add_signal_handler` method:: ...@@ -1601,7 +1601,7 @@ using the :meth:`loop.add_signal_handler` method::
import os import os
import signal import signal
def ask_exit(signame): def ask_exit(signame, loop):
print("got signal %s: exit" % signame) print("got signal %s: exit" % signame)
loop.stop() loop.stop()
...@@ -1611,7 +1611,7 @@ using the :meth:`loop.add_signal_handler` method:: ...@@ -1611,7 +1611,7 @@ using the :meth:`loop.add_signal_handler` method::
for signame in {'SIGINT', 'SIGTERM'}: for signame in {'SIGINT', 'SIGTERM'}:
loop.add_signal_handler( loop.add_signal_handler(
getattr(signal, signame), getattr(signal, signame),
functools.partial(ask_exit, signame)) functools.partial(ask_exit, signame, loop))
await asyncio.sleep(3600) await asyncio.sleep(3600)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment