Closed ihucos closed 8 years ago
I know that I personally haven't had any use-case where reloading the module would make sense, and it would be unsurprising to me that Django would have problems with it in general. Would you be willing to expand your use-case for reloading the modules?
Would you be willing to expand your use-case for reloading the modules?
Unfortunately I could not find what does the reload, the exception could also be caused by something completely else. My guess is, that it is gunicorn trying to respawn when the celery server could no be reached, and that possibly related to the use of "--preload". But I could not reproduce that. So really no idea.
i think i have the exact same issue, causing responses on production to take more than 4 seconds and i had to migrate back on version 0.3...
@mpetyx : If moving back to 0.3 fixed your issue, than that's more likely because of the default for Celery Procs to inspect all the types of tasks on the workers. For me, and what seemed like the typical use-case, not inspecting those caused innaccurate data, which was a bigger problem than the additional response time.
If the trade-off is right for you, then you can add inspect_statuses = []
to your Proc definition to signal that tasks that are already owned by workers (running, reserved, or scheduled) should not be counted.
For example:
MyProc(CeleryProc):
name = 'my_proc'
queues = ['my_queue']
inspect_statuses = []
This is documented at https://hirefire.readthedocs.io/en/latest/procs/#celery
I hope that helps. If you confirm that it is indeed an issue with procs being registered multiple times, then please let us know your use-case for that ability, as it doesn't make much sense to us yet.
i would have to check this on production level, so it may take some time. thank you very much for your quick reply!
I'm closing this, as it appears that it's likely invalid. If you disagree, feel free to make a case to re-open it. For now, I don't know that it's reasonable to assume that Django Middleware (or other things, like models) can reasonably be reloaded.
In our setup that class attribute definition gets execute two times: https://github.com/jezdez/hirefire/blob/e29ef21ffdece81967117b12a73692b37887e28f/hirefire/contrib/django/middleware.py#L33
I can reproduce our exception using
reload
on the middleware module and don't know any other way how that line can get evaluated multiple times. So the question is maybe if Django middlewares are supposed to survive areload
or not.Our fix was to just don't complain when procs gets loaded multiple times. https://github.com/resmio/hirefire/commit/3bb23433a34ef73b3604ee5536c1305ade8b842a
This is our traceback: