This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pfreixes
Recipients pfreixes, yselivanov
Date 2017-05-26.20:59:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495832374.38.0.182460539379.issue30490@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2017-05-26 20:59:34pfreixessetrecipients: + pfreixes, yselivanov
2017-05-26 20:59:34pfreixessetmessageid: <1495832374.38.0.182460539379.issue30490@psf.upfronthosting.co.za>
2017-05-26 20:59:34pfreixeslinkissue30490 messages
2017-05-26 20:59:34pfreixescreate