Skip to content

Instantly share code, notes, and snippets.

@Natim
Created April 7, 2014 19:56
Show Gist options
  • Select an option

  • Save Natim/10040626 to your computer and use it in GitHub Desktop.

Select an option

Save Natim/10040626 to your computer and use it in GitHub Desktop.
AsyncIO LS
import asyncio.subprocess
@asyncio.coroutine
def demo():
proc = yield from asyncio.create_subprocess_exec('ls', '-1', stdout=asyncio.subprocess.PIPE)
while True:
line = yield from proc.stdout.readline()
if not line:
break
print(line)
loop = asyncio.get_event_loop()
loop.run_until_complete(demo())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment