Skip to content

Commit f8091e7

Browse files
committed
Fix test failures by not cleaning up watcher in test for issue python#168.
1 parent c80a657 commit f8091e7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/test_streams.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,6 @@ def test_read_all_from_pipe_reader(self):
593593
# of the data writter. Also we must explicitly attach a child
594594
# watcher to the event loop.
595595

596-
watcher = asyncio.get_child_watcher()
597-
watcher.attach_loop(self.loop)
598-
599596
code = """\
600597
import os, sys
601598
fd = int(sys.argv[1])
@@ -611,9 +608,15 @@ def test_read_all_from_pipe_reader(self):
611608
transport, _ = self.loop.run_until_complete(
612609
self.loop.connect_read_pipe(lambda: protocol, pipe))
613610

614-
proc = self.loop.run_until_complete(
615-
asyncio.create_subprocess_exec(*args, pass_fds={wfd}, loop=self.loop))
616-
self.loop.run_until_complete(proc.wait())
611+
watcher = asyncio.SafeChildWatcher()
612+
watcher.attach_loop(self.loop)
613+
try:
614+
asyncio.set_child_watcher(watcher)
615+
proc = self.loop.run_until_complete(
616+
asyncio.create_subprocess_exec(*args, pass_fds={wfd}, loop=self.loop))
617+
self.loop.run_until_complete(proc.wait())
618+
finally:
619+
asyncio.set_child_watcher(None)
617620

618621
os.close(wfd)
619622
data = self.loop.run_until_complete(reader.read(-1))

0 commit comments

Comments
 (0)