You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2017-07-19.20:48:00.009>created_at=<Date2017-05-26.20:59:34.365>labels= ['3.7', 'expert-asyncio']
title='Allow pass an exception to the Event.set method'updated_at=<Date2017-07-19.20:48:00.007>user='https://github.com/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.
ifkeyinthrottle_dns_events:
yieldfromthrottle_dns_events[key].wait()
else:
throttle_dns_events[key] =Event(loop=loop)
try:
addrs=yieldfrom \
resolver.resolve(host, port, family=family)
cached_hosts.add(key, addrs)
throttle_dns_events[key].set()
exceptExceptionase:
# any DNS exception, independently of the implementation# is set for the waiters to raise the same exception.throttle_dns_events[key].set(exc=e)
raisefinally:
throttle_dns_events.pop(key)
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: