Skip to content

Fix InMemoryBroker to use startup and shutdown middleware hooks#629

Open
PythonFZ wants to merge 3 commits into
taskiq-python:masterfrom
PythonFZ:fix-inmem-broker-middleware
Open

Fix InMemoryBroker to use startup and shutdown middleware hooks#629
PythonFZ wants to merge 3 commits into
taskiq-python:masterfrom
PythonFZ:fix-inmem-broker-middleware

Conversation

@PythonFZ

Copy link
Copy Markdown

A copy/paste approach + test similar to #358

Instead of relying on super calls this PR just copy + pastes

taskiq/taskiq/abc/broker.py

Lines 196 to 198 in 9f8db96

for middleware in self.middlewares:
if middleware.__class__.startup != TaskiqMiddleware.startup:
await maybe_awaitable(middleware.startup())

and

taskiq/taskiq/abc/broker.py

Lines 217 to 219 in 9f8db96

for middleware in self.middlewares:
if middleware.__class__.shutdown != TaskiqMiddleware.shutdown:
await maybe_awaitable(middleware.shutdown())

into the methods of class InMemoryBroker(AsyncBroker) and adds a simple test case checking ensuring startup and shutdown work and the order of execution is correct.

@PythonFZ

PythonFZ commented Jul 22, 2026

Copy link
Copy Markdown
Author

@s3rius Thanks for approving the PR. Could you re-run the CI / merge main again. The error doesn't seem to be related to the changed I made.

@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.06%. Comparing base (9f8db96) to head (a62189e).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #629      +/-   ##
==========================================
+ Coverage   79.79%   80.06%   +0.26%     
==========================================
  Files          69       69              
  Lines        2529     2538       +9     
==========================================
+ Hits         2018     2032      +14     
+ Misses        511      506       -5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants