mirror of
https://github.com/python/cpython.git
synced 2025-09-12 11:46:52 +00:00
parent
e82881cea7
commit
b5cace8980
1 changed files with 17 additions and 33 deletions
|
@ -609,41 +609,25 @@ os.close(fd)
|
||||||
rfd, wfd = os.pipe()
|
rfd, wfd = os.pipe()
|
||||||
args = [sys.executable, '-c', code, str(wfd)]
|
args = [sys.executable, '-c', code, str(wfd)]
|
||||||
|
|
||||||
# FIXME: Debug code for issue #21645
|
pipe = open(rfd, 'rb', 0)
|
||||||
import logging
|
reader = asyncio.StreamReader(loop=self.loop, limit=1)
|
||||||
self.loop.set_debug(True)
|
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
|
||||||
logger = logging.getLogger('asyncio')
|
transport, _ = self.loop.run_until_complete(
|
||||||
log_level = logger.level
|
self.loop.connect_read_pipe(lambda: protocol, pipe))
|
||||||
|
|
||||||
|
watcher = asyncio.SafeChildWatcher()
|
||||||
|
watcher.attach_loop(self.loop)
|
||||||
try:
|
try:
|
||||||
log_handler = logging.StreamHandler(sys.__stderr__)
|
asyncio.set_child_watcher(watcher)
|
||||||
logger.addHandler(log_handler)
|
proc = self.loop.run_until_complete(
|
||||||
logger.setLevel(logging.DEBUG)
|
asyncio.create_subprocess_exec(*args, pass_fds={wfd}, loop=self.loop))
|
||||||
# FIXME: Debug code for issue #21645 ---
|
self.loop.run_until_complete(proc.wait())
|
||||||
|
|
||||||
pipe = open(rfd, 'rb', 0)
|
|
||||||
reader = asyncio.StreamReader(loop=self.loop, limit=1)
|
|
||||||
protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop)
|
|
||||||
transport, _ = self.loop.run_until_complete(
|
|
||||||
self.loop.connect_read_pipe(lambda: protocol, pipe))
|
|
||||||
|
|
||||||
watcher = asyncio.SafeChildWatcher()
|
|
||||||
watcher.attach_loop(self.loop)
|
|
||||||
try:
|
|
||||||
asyncio.set_child_watcher(watcher)
|
|
||||||
proc = self.loop.run_until_complete(
|
|
||||||
asyncio.create_subprocess_exec(*args, pass_fds={wfd}, loop=self.loop))
|
|
||||||
self.loop.run_until_complete(proc.wait())
|
|
||||||
finally:
|
|
||||||
asyncio.set_child_watcher(None)
|
|
||||||
|
|
||||||
os.close(wfd)
|
|
||||||
data = self.loop.run_until_complete(reader.read(-1))
|
|
||||||
self.assertEqual(data, b'data')
|
|
||||||
finally:
|
finally:
|
||||||
# FIXME: Debug code for issue #21645
|
asyncio.set_child_watcher(None)
|
||||||
logger.removeHandler(log_handler)
|
|
||||||
logger.setLevel(log_level)
|
os.close(wfd)
|
||||||
# FIXME: Debug code for issue #21645 ---
|
data = self.loop.run_until_complete(reader.read(-1))
|
||||||
|
self.assertEqual(data, b'data')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue