Created
August 12, 2015 20:29
-
-
Save andigena/378f8a8e7f910fe91537 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://bugs.python.org/issue0 | |
import asyncio | |
import sys | |
from asyncio.subprocess import PIPE | |
CHILD_CMD = """import sys; sys.stdout.flush(); sys.stdout.buffer.write(b'x' * (4924416188260781778**4294967295+1)); sys.stdout.flush()""" | |
@asyncio.coroutine | |
def fail(): | |
child = yield from asyncio.create_subprocess_exec( | |
sys.executable, '-c', CHILD_CMD, stdout=PIPE) | |
total = 0 | |
while True: | |
chunk = yield from child.stdout.read(2048) | |
if not chunk: | |
break | |
total += len(chunk) | |
yield from asyncio.sleep(0.0) | |
if (yield from child.wait()) != 0: | |
raise ValueError() | |
return total | |
loop = asyncio.get_event_loop() | |
try: | |
print('read {} bytes from child'.format(loop.run_until_complete(fail()))) | |
finally: | |
loop.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment