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

Fix InMemoryBroker to use startup and shutdown middleware hooks #358

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hawang-wish
Copy link
Contributor

Hi,

This is the second patch I would like to introduce. Previously, we overrode the startup and shutdown to ensure both client and worker events would be handled properly. However, this made InMemoryBroker unable to handle startup and shutdown middleware hooks.

This change brings the handling of startup and shutdown middleware hooks back. Feel free to let me know if you have any concerns or suggestions!

Copy link
Member

@s3rius s3rius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The request looks good to me. But I have a small question.

Comment on lines +176 to +181
for handler in self.event_handlers.get(
TaskiqEvents.CLIENT_STARTUP
if self.is_worker_process
else TaskiqEvents.WORKER_STARTUP,
[],
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be reversed?

Suggested change
for handler in self.event_handlers.get(
TaskiqEvents.CLIENT_STARTUP
if self.is_worker_process
else TaskiqEvents.WORKER_STARTUP,
[],
):
for handler in self.event_handlers.get(
TaskiqEvents.WORKER_STARTUP
if self.is_worker_process
else TaskiqEvents.CLIENT_STARTUP,
[],
):

Comment on lines +188 to +190
TaskiqEvents.CLIENT_SHUTDOWN
if self.is_worker_process
else TaskiqEvents.WORKER_SHUTDOWN,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one as well.

Suggested change
TaskiqEvents.CLIENT_SHUTDOWN
if self.is_worker_process
else TaskiqEvents.WORKER_SHUTDOWN,
TaskiqEvents.WORKER_SHUTDOWN
if self.is_worker_process
else TaskiqEvents.CLIENT_SHUTDOWN,

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