[issue30490] Allow pass an exception to the Event.set method

2017-07-19 Thread pfreixes

pfreixes added the comment:

More info about why here 
https://github.com/python/cpython/pull/1824#issuecomment-315903808

--
resolution:  -> rejected
stage:  -> 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



[issue30490] Allow pass an exception to the Event.set method

2017-05-26 Thread pfreixes

Changes by pfreixes :


--
pull_requests: +1911

___
Python tracker 

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



[issue30490] Allow pass an exception to the Event.set method

2017-05-26 Thread pfreixes

New submission from pfreixes:

Having the Event as the way to synchronize 1:N coroutines, the none happy path 
should be able to be expressed making possible call the `set_exception` for 
each future related to each waiter.

As an example the following code trying to implement a way to avoid the dogpile 
effect for a DNS cache. If the coro that holds the event fails, the original 
exception is also broadcasted to the waiters.


if key in throttle_dns_events:
yield from throttle_dns_events[key].wait()
else:
throttle_dns_events[key] = Event(loop=loop)
try:
addrs = yield from \
resolver.resolve(host, port, family=family)
cached_hosts.add(key, addrs)
throttle_dns_events[key].set()
except Exception as e:
# any DNS exception, independently of the implementation
# is set for the waiters to raise the same exception.
throttle_dns_events[key].set(exc=e)
raise
finally:
throttle_dns_events.pop(key)

--
components: asyncio
messages: 294572
nosy: pfreixes, yselivanov
priority: normal
severity: normal
status: open
title: Allow pass an exception to the Event.set method
versions: Python 3.7

___
Python tracker 

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