Skip to content

Conversation

@ricardogsilva
Copy link

This PR adds a cookbook recipe showing how to integrate dramatiq when using a factory function application pattern.

This is something which has been discussed in some issues in the past, for example:

It seems supporting this use case is not part of dramatiq's design, but it is something which would be beneficial to have as a cookbook entry.

The approach proposed in this PR is different from the ones mentioned in the aforementioned issues. It boils down to using a StubBroker as the initial broker, to which tasks are registered. This means that at import time, the stub broker is being used and causes no eager connection attempts.
Then the stub broker is replaced by the real worker inside the application factory function, after the actual broker settings are already known.

@ricardogsilva ricardogsilva changed the title Added instructions on how to do lazy init with sub broker cookbook recipe for lazy init with sub broker Aug 20, 2025
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.

1 participant