Created
April 7, 2014 19:56
-
-
Save Natim/10040626 to your computer and use it in GitHub Desktop.
AsyncIO LS
This file contains hidden or 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
| 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