Closed dnmellen closed 3 years ago
I know that I can pass an instance of the middleware in the settings (ie: TimeLimit middleware)
DRAMATIQ_BROKER = {
"BROKER": "dramatiq.brokers.stub.StubBroker",
"OPTIONS": {},
"MIDDLEWARE": [
"dramatiq.middleware.AgeLimit",
TimeLimit(time_limit=36000000), <-------
"dramatiq.middleware.Retries",
"django_dramatiq.middleware.AdminMiddleware",
"django_dramatiq.middleware.DbConnectionsMiddleware",
]
}
But GroupCallbacks
middleware needs the rate_limiter_backend which is defined on the django_dramatiq
app initialization, so I'm not sure if I can access it in my settings.py
Yes, this is a problem right now. We could come up with some sort of protocol for referring to arguments from a settings.py middleware def, but I'm not sure what would be the common/idiomatic way to do something like this with Django settings. Suggestions would be appreciated.
I'm implementing a possible solution in this PR: https://github.com/Bogdanp/django_dramatiq/pull/83, but I'm still fighting with the tests.
Please check the PR #83. I couldn't add tests and anyone is welcome to modify it and add some tests (I had a hard time trying to modify the base test settings since I needed to change INSTALLED_APPS
settings and it won't work using the override_settings
decorator.
Now the PR does not add any tests but the code I added doesn't modify the current behavior of django_dramatiq
. I'm going to test my branch with my project. Consider this as a possible solution to this issue.
Closing since the associated PR has been merged. Thanks again!
Hi, I'm trying to use
GroupCallbacks
indjango_dramatiq
but it seems that callback is not really compatible:My settings:
Error:
GroupCallbacks initializer needs
rate_limiter_backend
as parameter:But django_dramatiq is not passing extra params when loading the middleware:
apps.py:
utils.py:
How can I use GroupCallbacks in django_dramatiq? Do I need to modify how django_dramatiq initializes or is there another way?
Thanks!