Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-07 Thread Yury Selivanov
On 2015-05-07 1:42 PM, Guido van Rossum wrote: On Tue, May 5, 2015 at 3:36 PM, Rajiv Kumar wrote: I wrote a little example[1] that has a bare-bones implementation of Go style channels via a custom event loop. I used it to translate the prime sieve example from Go[2] almost directly to Python

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-07 Thread Guido van Rossum
On Tue, May 5, 2015 at 3:36 PM, Rajiv Kumar wrote: > I wrote a little example[1] that has a bare-bones implementation of Go > style channels via a custom event loop. I used it to translate the prime > sieve example from Go[2] almost directly to Python. The code uses "message > = await channel.rec

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-07 Thread Ryan Hiebert
This draft proposal for async generators in ECMAScript 7 may be interesting reading to those who haven’t already: https://github.com/jhusain/asyncgenerator This talk also has some good ideas about them, though the interesting stuff about using async g

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-07 Thread Rajiv Kumar
I wrote a little example[1] that has a bare-bones implementation of Go style channels via a custom event loop. I used it to translate the prime sieve example from Go[2] almost directly to Python. The code uses "message = await channel.receive()" to mimic Go's "message <- channel". Instead of using

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-06 Thread Guido van Rossum
Thanks for these stats! (Though I'm sure there's some bias because Tkinter is in the stdlib and the others aren't. Stdlib status still counts a lot for many people, pip notwithstanding. (But that's a different thread. :-)) FWIW I tried to get the Tkinter-asyncio demo mentioned in the above thread

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-06 Thread Terry Reedy
On 5/6/2015 5:39 PM, Guido van Rossum wrote: Sorry to send you on such a wild goose chase! I did mean the issue you found #21). I just updated it with a link to a thread that has more news: https://groups.google.com/forum/#!searchin/python-tulip/tkinter/python-tulip/TaSVW-pjWro/hCP6qS4eRnAJ

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-06 Thread Guido van Rossum
Sorry to send you on such a wild goose chase! I did mean the issue you found #21). I just updated it with a link to a thread that has more news: https://groups.google.com/forum/#!searchin/python-tulip/tkinter/python-tulip/TaSVW-pjWro/hCP6qS4eRnAJ I wasn't able to verify the version by Luciano Ra

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-06 Thread Terry Reedy
On 5/5/2015 10:59 PM, Guido van Rossum wrote: For this you should probably use an integration of asyncio (which can do async subprocess output nicely) with Tkinter. Over in tulip-land there is an demo of such an integration. After redirection from googlecode tulip, I found https://github.com/py

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-06 Thread Yury Selivanov
Hi Ben, On 2015-05-06 12:05 AM, Ben Darnell wrote: On Tue, May 5, 2015 at 3:25 PM, Yury Selivanov wrote: Yes, there is no other popular event loop for 3.4 other than asyncio, that uses coroutines based on generators (as far as I know). Tornado supports Python 3.4 and uses generator-based co

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-06 Thread Greg Ewing
Terry Reedy wrote: What I do not understand is how io events become event loop Event instances. They don't become Events exactly, but you can register a callback to be called when a file becomes ready for reading or writing, see: http://effbot.org/pyfaq/can-i-have-tk-events-handled-while-wait

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Ben Darnell
On Tue, May 5, 2015 at 3:25 PM, Yury Selivanov wrote: > > Yes, there is no other popular event loop for 3.4 other > than asyncio, that uses coroutines based on generators > (as far as I know). > Tornado supports Python 3.4 and uses generator-based coroutines. We use `yield` instead of `yield fro

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Guido van Rossum
For this you should probably use an integration of asyncio (which can do async subprocess output nicely) with Tkinter. Over in tulip-land there is an demo of such an integration. On Tue, May 5, 2015 at 6:03 PM, Terry Reedy wrote: > On 5/5/2015 6:25 PM, Yury Selivanov wrote: > > Yes, there is no

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Terry Reedy
On 5/5/2015 6:25 PM, Yury Selivanov wrote: Yes, there is no other popular event loop for 3.4 other than asyncio, There is the tk(inter) event loop which also ships with CPython, and which is commonly used. that uses coroutines based on generators Oh ;-) Tkinter event loop is callback bas

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Guido van Rossum
I wonder if you could look at Tkinter for a very different view of the world. While there are ways to integrate socket I/O with the Tcl/Tk event loop, the typical Python app using Tkinter probably moves network I/O (if it has any) to a separate thread, and ignores the delays of disk-based I/O (beca

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Paul Moore
On 5 May 2015 at 23:28, Guido van Rossum wrote: >> At this point, *all* I'm thinking of is a toy. So, an implementation >> somewhat parallel to asyncio, but where the event loop just passes >> control to the next task - so no IO multiplexing. Essentially Greg >> Ewing's example up to, but not incl

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Paul Moore
On 5 May 2015 at 23:25, Yury Selivanov wrote: >> Note that I don't have a problem with there being no existing >> implementation other than asyncio. I'd just like it if we could be >> clear over exactly what we mean when we say "the PEP is not tied to >> asyncio". > > Well, "the PEP is not tied to

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Guido van Rossum
On Tue, May 5, 2015 at 2:40 PM, Paul Moore wrote: > On 5 May 2015 at 22:25, Guido van Rossum wrote: > [Paul:] > >> I'd be interested in writing, for instructional purposes, a toy but > >> complete event loop. But I'm *not* really interested in trying to > >> reverse engineer the required interf

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Yury Selivanov
Paul, On 2015-05-05 5:54 PM, Paul Moore wrote: On 5 May 2015 at 22:38, Yury Selivanov wrote: n 2015-05-05 5:01 PM, Paul Moore wrote: On 5 May 2015 at 21:00, Yury Selivanov wrote: On 2015-05-05 3:40 PM, Jim J. Jewett wrote: On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated P

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Paul Moore
On 5 May 2015 at 22:38, Yury Selivanov wrote: > n 2015-05-05 5:01 PM, Paul Moore wrote: >> >> On 5 May 2015 at 21:00, Yury Selivanov wrote: >>> >>> On 2015-05-05 3:40 PM, Jim J. Jewett wrote: On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated PEP492. Where

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Paul Moore
On 5 May 2015 at 22:25, Guido van Rossum wrote: >> I'd be interested in writing, for instructional purposes, a toy but >> complete event loop. But I'm *not* really interested in trying to >> reverse engineer the required interface. > > This is a great idea. What kind of application do you have in

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Yury Selivanov
On 2015-05-05 5:01 PM, Paul Moore wrote: On 5 May 2015 at 21:00, Yury Selivanov wrote: On 2015-05-05 3:40 PM, Jim J. Jewett wrote: On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated PEP492. Where are the following over-simplifications wrong? (1) The PEP is intended for use (a

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Guido van Rossum
On Tue, May 5, 2015 at 2:01 PM, Paul Moore wrote: > On 5 May 2015 at 21:00, Yury Selivanov wrote: > > On 2015-05-05 3:40 PM, Jim J. Jewett wrote: > >> > >> On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated > PEP492. > >> > >> Where are the following over-simplifications wrong? >

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Paul Moore
On 5 May 2015 at 21:00, Yury Selivanov wrote: > On 2015-05-05 3:40 PM, Jim J. Jewett wrote: >> >> On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated PEP492. >> >> Where are the following over-simplifications wrong? >> >> (1) The PEP is intended for use (almost exclusively) with >>

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Guido van Rossum
One small clarification: On Tue, May 5, 2015 at 12:40 PM, Jim J. Jewett wrote: > [...] but I don't understand how this limitation works with things like a > per-line file iterator that might need to wait for the file to > be initially opened. > Note that PEP 492 makes it syntactically impossib

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Nathaniel Smith
On May 5, 2015 12:40 PM, "Jim J. Jewett" wrote: > > > On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated PEP492. > > Where are the following over-simplifications wrong? > [...snip...] > > [Note that the actual PEP uses iteration over the results of a new > __await__ magic method, ra

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Yury Selivanov
On 2015-05-05 3:40 PM, Jim J. Jewett wrote: On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated PEP492. Where are the following over-simplifications wrong? (1) The PEP is intended for use (almost exclusively) with asychronous IO and a scheduler such as the asynchio event loop.

Re: [Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Jim J. Jewett
On Tue May 5 18:29:44 CEST 2015, Yury Selivanov posted an updated PEP492. Where are the following over-simplifications wrong? (1) The PEP is intended for use (almost exclusively) with asychronous IO and a scheduler such as the asynchio event loop. (2) The new syntax is intended to make it eas

[Python-Dev] PEP 492: async/await in Python; version 5

2015-05-05 Thread Yury Selivanov
Hi python-dev, Updated version of the PEP is below. Quick summary of changes: 1. set_coroutine_wrapper and get_coroutine_wrapper functions are now thread-specific (like settrace etc). 2. Updated Abstract & Rationale sections. 3. RuntimeWarning is always raised when a coroutine wasn't awaited