Roel van der Goot <roelvanderg...@gmail.com> added the comment: I have been thinking about my previous comment a bit more. For consistency there should at least be an await somewhere to move back from async land to non-async land.
For example: #!/usr/bin/env python3 import asyncio async def main(): cmds = [['ssh', 'user@host', 'echo {}'.format(i)] for i in range(4)] creations = [asyncio.create_subprocess_exec(*cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE) for cmd in cmds] processes = [await creation for creation in creations] outputs = [await process.communicate() for process in processes] print(outputs) if __name__ == '__main__': event_loop = asyncio.get_event_loop() event_loop.run_until_complete(main()) prints [(b'0\n', b''), (b'1\n', b''), (b'2\n', b''), (b'3\n', b'')] It would be nice if you could somehow return outputs from main() and process the results in a non-async function. There are no async concepts left in outputs after all. But I am not aware of a way you can do this in Python currently. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31832> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com