Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ceb842e

Browse files
alvassinmiss-islington
authored andcommitted
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.
1 parent c1964e9 commit ceb842e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Doc/library/asyncio-eventloop.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,7 @@ using the :meth:`loop.add_signal_handler` method::
16011601
import os
16021602
import signal
16031603

1604-
def ask_exit(signame):
1604+
def ask_exit(signame, loop):
16051605
print("got signal %s: exit" % signame)
16061606
loop.stop()
16071607

@@ -1611,7 +1611,7 @@ using the :meth:`loop.add_signal_handler` method::
16111611
for signame in {'SIGINT', 'SIGTERM'}:
16121612
loop.add_signal_handler(
16131613
getattr(signal, signame),
1614-
functools.partial(ask_exit, signame))
1614+
functools.partial(ask_exit, signame, loop))
16151615

16161616
await asyncio.sleep(3600)
16171617

0 commit comments

Comments
 (0)