try:
return await waiter
finally:
# TODO: Use a context manager to add and remove the keys.
for key in keys:
self._waiters[key].discard(waiter)
if handle:
handle.cancel()
def notify(s
>>> try:
>>> return await waiter
>>> finally:
>>> # TODO: Use a context manager to add and remove the keys.
>>> for key in keys:
>>> self._waiters[key].discard(waiter)
>>> if handle:
>>> handle.cancel()
>>>
>>> def notify(self, key, m
>
> It is very annoying that async, await, yield, Future, Condition, Lock
> and almost all other async constructs work with any event loop; but
> simple things like "sleep for 10 seconds" are totally incompatible.
> But I guess I'll have to live with that for now.
>
Some more incompatibilty:
*
> Sorry, I didn't realize that you were using tornado and not asyncio.
> Presumably it should be on whatever loop the wait call was awaited in,
> but I have no idea how compatible asyncio constructs are with tornado
> event loops.
Exactly. I had the same doubts.
> I think it's a bad idea because t
On Thu, Oct 15, 2015 at 11:16 AM, Nagy László Zsolt
wrote:
> In order to schedule a callback in the future, you would have to have a
> standard event loop interface for scheduling. We do have a base class
> asyncio.BaseEventLoop, but tornado's ioloop is NOT a descendant of it.
> (It is based on to
>> async def waitfor(self, keys, timeout=None):
>> """Wait until a message comes in for any of the given key(s). Raise
>> BusTimeoutError after the given timedelta."""
>>
>>
>>
>> Internally, the waitfor method would use the add_timeout to resume itself
>> and raise the Bu
On Thu, Oct 15, 2015 at 5:25 AM, Nagy László Zsolt wrote:
> I'm new to Python 3.5 async / await syntax. I would like to create a class -
> let's call it AsyncBus - that can be used to listen for keys, and send
> messages for keys ansynchronously.
>
> class BusTimeoutError(Exception):
> pass
>
> async def waitfor(self, keys, timeout=None):
> """Wait for keys.
>
> :arg keys: An iterable of immutable keys.
> :arg timeout: Raise TimeoutError if nothing hits the
> bus for this amount of time.
> None means: wait indefinitely. It
I'm new to Python 3.5 async / await syntax. I would like to create a
class - let's call it AsyncBus - that can be used to listen for keys,
and send messages for keys ansynchronously.
class BusTimeoutError(Exception):
pass
class AsyncBus(object):
def __init__(self, add_timeout):
""