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

Improve functionality and consistency of Sanic.event() #2827

Merged
merged 5 commits into from
Dec 7, 2023

Conversation

talljosh
Copy link
Contributor

@talljosh talljosh commented Sep 25, 2023

This PR makes the following changes:

  • app.event() now takes additional arguments condition and exclusive which behave the same as the same arguments to app.signal()
  • blueprint.event() now takes additional argument condition which behaves the same as the same arguments to blueprint.signal()
  • app.event() and blueprint.event() now accept an event in enum form as well as str form, consistent with app.signal() and blueprint.signal()
  • app.event() and blueprint.event() now return a copy of the context dict passed to app.dispatch() (Signal event to return context #2088)
  • blueprint.event() now raises TimeoutError on timeout to be consistent with app.event() (previously, it just silently returned on timeout)
  • blueprint.event() now cancels any unfinished wait tasks instead of leaving them waiting
  • automatically registered signals no longer raise an error if they are dispatched with context
  • fixed Sanic.event() fires when any event in the group is dispatched #2826, where the wrong event was being triggered
  • more tests added for signals and events, and some existing tests updated

…fire for the specific requested event (sanic-org#2826).

Also added support for passing conditions= and exclusive= arguments to app.event().
@talljosh talljosh requested a review from a team as a code owner September 25, 2023 01:12
@codecov
Copy link

codecov bot commented Sep 25, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (4499d2c) 88.191% compared to head (9469f36) 88.219%.

Files Patch % Lines
sanic/blueprints.py 72.222% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2827       +/-   ##
=============================================
+ Coverage   88.191%   88.219%   +0.028%     
=============================================
  Files           93        93               
  Lines         7232      7275       +43     
  Branches      1242      1249        +7     
=============================================
+ Hits          6378      6418       +40     
- Misses         596       598        +2     
- Partials       258       259        +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ahopkins
ahopkins previously approved these changes Dec 7, 2023
@ahopkins ahopkins merged commit 5f0787b into sanic-org:main Dec 7, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sanic.event() fires when any event in the group is dispatched
2 participants