Skip to content

Make event handlers non-blocking by default #51

@FichteFoll

Description

@FichteFoll

Event handlers are currently executed in paralell fr the same priority, but in sequence overall and generally block the event queue until their completion. The intended workflow for non-blocking handlers is to create and schedule a task using the ReturnValue namedtuple, which the dispatcher waits for in the case the event handler needs to modify the event queue.

However, this use case is much more likely than modifying the queue and should thus be the default in order to reduce boilerplate code for the 90% case.

I'm currently thinking of adding a keyword argument to the event decorator, but I'm a bit out of touch with the code base since I haven't touched it in 3 years. Regardless, I'm creating this issue to remind myself of the problem. I should note that by doing this, order of execution is not guaranteed, but that should be self-evident by the meaning of "non-blocking" and is really no different from the status quo when a task is "scheduled for later".

Also related reading (and what kind of lead me to this thought): https://lucumr.pocoo.org/2020/1/1/async-pressure/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions