-
Notifications
You must be signed in to change notification settings - Fork 78
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
Test Hangs Waiting for Join #32
Comments
Any chance you could make a minimal reproducible example? Hard to say w/o any code to look at. |
Thanks for the response and I understand this is difficult without code. I tried to create a simple project to show the problem but I can't recreate it, yet. Is there additional logging I can enable somehow in the worker and/or broker to try to see what is happening? |
The easiest way would be to turn on debug logging on the root logger. Before all your tests, you can add:
With that you should start seeing debug logging from the broker and worker. |
I am not sure if this gives you any clues but here is the log from one of the failing tests. It looks to me like the tasks don't start running until after the timeout has occurred.
|
Are you doing any DB operations inside your tasks? Do you have the AdminMiddleware turned on? If so, maybe try turning it off and see if that helps. |
Thank you, AdminMiddleware was turned on. I turned it off and the timeouts are no longer occurring. Am I doing something wrong to cause this? Should AdminMiddleware not be used during tests? |
Hard to say w/o knowing the specifics of what DB you are using. Were these tests using |
Thanks again. Here is my database setup.
Here are all of my DRAMATIQ settings.
The test case in question does inherit from |
Thanks for the info. I'll try to reproduce this as soon as I can. |
I had similar problem. I use DRF and want to test my api view which sets up a dramatiq task.
It helped and my tests are working as I expected. Maybe it will help the others. BTW - Thanks a lot for a dramatiq. I just started to use it and it's amazing. |
I simply had a custom retry logic and a task that took long to compute, so it seemed that it hanged, while it was actually just trying to do these 20 long iterations :) |
Had this same issue and it took us an afternoon to troubleshoot, thanks @wwarne in #32 (comment) - would you accept a PR to update the docs with some of the content here? |
Very glad it helped! I'm not sure I understood the part about accepting a PR correctly. @shapiromatron could you please clarify a little? |
I faced the same issue recently and interestingly, as @Bogdanp mentioned:
Removing the |
I have some tests in my django projects that are hanging at both the
self.broker.join('default')
andself.worker.join()
lines. I know that it hangs at theself.worker.join()
line because I added atry/except
block around theself.broker.join('default', timeout=5000)
with the timeout added. These tests rely on my django views tosend()
to the dramatiq tasks in tasks.py.I added print statements at the beginning and end of all of my actor tasks and I see them print when the timeout is reached.
I have some other tests that
send()
to the tasks directly and those tests are working perfectly.I am using the StubBroker in my settings.
If I run the rabbitmq broker with a worker and
manage.py runserver
, I can see all of the tasks are executing successfully.Do you have any suggestions on how to troubleshoot this?
The text was updated successfully, but these errors were encountered: