Skip to content

Instantly share code, notes, and snippets.

@detly
Last active August 29, 2015 14:18
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 detly/8f936259753e4a23b50c to your computer and use it in GitHub Desktop.
Save detly/8f936259753e4a23b50c to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import asyncio
import sys
import pexpect
@asyncio.coroutine
def run():
cmd = ' '.join([
sys.executable,
'-c \'raise SystemExit("Blorp")\''
])
p = pexpect.spawn(cmd)
while True:
try:
_ = yield from p.expect_exact('\r', async=True)
except pexpect.EOF:
print("p.eof(): {:s}".format(str(p.eof())))
break
def main():
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
loop.close()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment