[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-08-18 Thread Guido van Rossum

Guido van Rossum added the comment:

Let's not do this.

--
resolution:  -> rejected
stage: test needed -> resolved
status: open -> closed

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-08-18 Thread Matt Rasband

Matt Rasband added the comment:

I attempted this myself, it seemed to have too many costs associated for the 
stdlib and is something easy enough to wrap myself when I need this 
functionality with explicit semantics on how to "stop" the queue (using an 
`object()` sentinel). My implementation is flawed as the sentinel is global, 
instead of per queue instance, if you decide to use this at all.

See https://github.com/python/asyncio/pull/445

--
nosy: +Matt Rasband

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-08-03 Thread Guido van Rossum

Guido van Rossum added the comment:

So that's an infinite loop right?

--

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-08-03 Thread Georgy

Georgy added the comment:

I successfully use my code:

import asyncio, sanic

class MyQueue(asyncio.Queue):
def __aiter__(self): return self
async def __anext__(self): return await self.get()

app = sanic.Sanic()
ws_set = set()
app.static('/', 'async.html')

@app.websocket('/ws')
async def root_ws(request, ws):
ws_set.add(ws)
try:
while True: await ws.recv()
finally: ws_set.remove(ws)

async def postgres():
import aiopg
async with aiopg.create_pool('') as pool:
async with pool.acquire() as connection:
connection._notifies = MyQueue()
async with connection.cursor() as cursor:
await cursor.execute('LISTEN message')
async for message in connection.notifies:
for ws in ws_set: await ws.send(message.payload)

try: 
asyncio.get_event_loop().run_until_complete(asyncio.gather(app.create_server(), 
postgres()))
except KeyboardInterrupt: asyncio.get_event_loop().stop()

--

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-07-25 Thread Guido van Rossum

Guido van Rossum added the comment:

> > there's no way to end the loop on the producing side.

> I might be missing something, but can't something similar be said of 
> queue.get()?

That's my point, actually. If you are wrapping the Queue protocol with 
__aiter__/__anext__ the caller would expect there's a way to signal to the 
latter that the loop is over (so it can raise StopAsyncIteration). But since 
.get() doesn't have a way to signal this, an async for-loop would not be able 
to terminate (other than through break).

--

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-07-25 Thread Chris Jerdonek

Chris Jerdonek added the comment:

> there's no way to end the loop on the producing side.

I might be missing something, but can't something similar be said of 
queue.get()?

--

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2017-07-25 Thread Chris Jerdonek

Changes by Chris Jerdonek :


--
nosy: +chris.jerdonek

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2016-11-25 Thread Guido van Rossum

Guido van Rossum added the comment:

Also it's not clear that it's a good idea without more thought -- there's no 
way to end the loop on the producing side.

--

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2016-11-25 Thread Guido van Rossum

Guido van Rossum added the comment:

This should be an upstream PR first (GitHub.com/python/asyncio). Also, too late 
for 3.6.

--
versions:  -Python 3.5, Python 3.6

___
Python tracker 

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



[issue28777] Add asyncio.Queue __aiter__, __anext__ methods

2016-11-25 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
stage:  -> test needed
title: asinc iter queue -> Add asyncio.Queue __aiter__, __anext__ methods
versions: +Python 3.6, Python 3.7

___
Python tracker 

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