-
Notifications
You must be signed in to change notification settings - Fork 79
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
dramatiq.set_broker(broker) in Phase 3 #26
Comments
I'm going to make it set up the broker before |
Hi Bogdanp I'm facing the same issue. Any updates on this? |
@sergioshev I made the change in 29646b0 . What are you trying to do and what is the exact issue you're running into? |
I came up here from Bogdanp/dramatiq#168. I followed your example from django dramatiq in github. Defined a simple actor but after calling my tasks.py I'm getting and error. When I run rundramatiq all workers are ok, and tasks module is detected.
tasks.py is very simple
Thank you Bogdan for your time. |
Maybe the problem lies with the fact, that you called Try your luck with the suggested DRAMATIQ_BROKER configuration in settings.py, see Installation instructions in the README of this repo. |
Thank you for your response. I have settings.py exactly as described in the example.
But if I remove manual setting for RedisBroker from tesks.py, HOC actor is failing with this error
For some reason HOC is trying to use rabbitmq. BTW is a fresh/clean django setup (django/django-dramatiq) in Debian stable (stretch). After setting the broker to redis by hand, I see error as above (Actor not found). No clue that is wrong with my set up. |
Ah, I think I got it! Everything is pretty clear once you follow the stack trace, step by step. You are loading default settings. Why? Because you call the tasks via a self-running script (I see @Bogdanp DramatiqException: Hello clumsy! Dramatiq is not configured! Did you forget to set your broker?
DjangoDramatiqException: Hello clumsy! Django-Dramatiq is not configured! Did you call the task from a working Django application with a properly configured 'DRAMATIQ_BROKER' in the settings? |
Thank you @CapedHero . I'll will try your suggestion. |
Yes, I'm inclined to agree. I'll consider this as a potential breaking change in 2.0. @sergioshev I believe @CapedHero is right. The issue is that you're trying to enqueue the messages from a standalone python script. |
I suspect I found a case when django_dramatiq is too late to set global_broker configured from settings, and actor decorator gets default RabbitMq broker from get_broker()
Django app registry populate consists of three phases:
Hence, in my case the models.py imports a task from tasks.py. That happens on Phase 2, prior to the moment of ready() of DjangoDramatiqConfig is called.
I understand that broker initialization must be put into the ready() due to middleware that can require apps to be initialized first. However resolving this issue could improve quality of life a lot.
As for now, I guess local imports of task will do.
Kind regards,
Serj
The text was updated successfully, but these errors were encountered: