[issue31830] asyncio.create_subprocess_exec doesn't capture all stdout output

2017-10-20 Thread Roel van der Goot

Change by Roel van der Goot :


--
components: asyncio
files: show.py
nosy: cannedrag, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.create_subprocess_exec doesn't capture all stdout output
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47228/show.py

___
Python tracker 
<https://bugs.python.org/issue31830>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot

New submission from Roel van der Goot :

$ python3
Python 3.6.3 (default, Oct  3 2017, 21:45:48) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> async def arange(n):
... for i in range(n):
... yield i
... 
>>> [i async for i in arange(10)]
  File "", line 1
[i async for i in arange(10)]
   ^
SyntaxError: invalid syntax
>>>

--
components: asyncio
messages: 304688
nosy: cannedrag, yselivanov
priority: normal
severity: normal
status: open
title: Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3
versions: Python 3.6

___
Python tracker 
<https://bugs.python.org/issue31832>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot

Roel van der Goot  added the comment:

Zachary,

Thank you for your response. I had the impression that async comprehensions are 
a bridge between async functions and non-async functions. Is there a wat to use 
async (and asyncio) and then go back to regular python? Or am I just wishful 
thinking? :-)

For example, it would be nice to start multiple processes through 
asyncio.create_subprocess_exec (or _shell) await twice and then process all the 
output in "traditional" (i.e., non-async) Python.

Cheers :),
Cannedrag

--

___
Python tracker 
<https://bugs.python.org/issue31832>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot

Roel van der Goot  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 
<https://bugs.python.org/issue31832>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot

Roel van der Goot  added the comment:

Thank you!

--

___
Python tracker 
<https://bugs.python.org/issue31832>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com