Skip to content

Instantly share code, notes, and snippets.

@andigena
Created August 12, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andigena/378f8a8e7f910fe91537 to your computer and use it in GitHub Desktop.
Save andigena/378f8a8e7f910fe91537 to your computer and use it in GitHub Desktop.
#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