Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pass an exception to the Event.set method #74675

Closed
pfreixes mannequin opened this issue May 26, 2017 · 2 comments
Closed

Allow pass an exception to the Event.set method #74675

pfreixes mannequin opened this issue May 26, 2017 · 2 comments
Labels

Comments

@pfreixes
Copy link
Mannequin

pfreixes mannequin commented May 26, 2017

BPO 30490
Nosy @1st1, @pfreixes
PRs
  • bpo-30490: Allow to the Event.set method pass an exception #1824
  • 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 = None
    closed_at = <Date 2017-07-19.20:48:00.009>
    created_at = <Date 2017-05-26.20:59:34.365>
    labels = ['3.7', 'expert-asyncio']
    title = 'Allow pass an exception to the Event.set method'
    updated_at = <Date 2017-07-19.20:48:00.007>
    user = 'https://github.com/pfreixes'

    bugs.python.org fields:

    activity = <Date 2017-07-19.20:48:00.007>
    actor = 'pfreixes'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-07-19.20:48:00.009>
    closer = 'pfreixes'
    components = ['asyncio']
    creation = <Date 2017-05-26.20:59:34.365>
    creator = 'pfreixes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30490
    keywords = []
    message_count = 2.0
    messages = ['294572', '298688']
    nosy_count = 2.0
    nosy_names = ['yselivanov', 'pfreixes']
    pr_nums = ['1824']
    priority = 'normal'
    resolution = 'rejected'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue30490'
    versions = ['Python 3.7']

    @pfreixes
    Copy link
    Mannequin Author

    pfreixes mannequin commented May 26, 2017

    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)

    @pfreixes pfreixes mannequin added 3.7 (EOL) end of life topic-asyncio labels May 26, 2017
    @pfreixes
    Copy link
    Mannequin Author

    pfreixes mannequin commented Jul 19, 2017

    More info about why here #1824 (comment)

    @pfreixes pfreixes mannequin closed this as completed Jul 19, 2017
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants