Skip to content
This repository was archived by the owner on Nov 23, 2017. It is now read-only.

Commit f348122

Browse files
author
Vincent Michel
committed
Refuse handlers if the child watcher has no loop attached
1 parent ad2ae67 commit f348122

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

asyncio/unix_events.py

+11
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,11 @@ def __exit__(self, a, b, c):
802802
pass
803803

804804
def add_child_handler(self, pid, callback, *args):
805+
if self._loop is None:
806+
raise RuntimeError(
807+
"Cannot add child handler, "
808+
"the child watcher does not have a loop attached")
809+
805810
self._callbacks[pid] = (callback, args)
806811

807812
# Prevent a race condition in case the child is already terminated.
@@ -898,6 +903,12 @@ def __exit__(self, a, b, c):
898903

899904
def add_child_handler(self, pid, callback, *args):
900905
assert self._forks, "Must use the context manager"
906+
907+
if self._loop is None:
908+
raise RuntimeError(
909+
"Cannot add child handler, "
910+
"the child watcher does not have a loop attached")
911+
901912
with self._lock:
902913
try:
903914
returncode = self._zombies.pop(pid)

0 commit comments

Comments
 (0)