-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Update celery task discovery config. #25479
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
Conversation
jmbowman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one suggestion for further cleanup, which can probably wait until after we determine if this even works.
Update the celery startup code to more closely match the docs. We believe some of these imports are causeing circulare dependencies that are causing race conditions in task discovery. Since all django apps should be loaded using the django fixup in celery 4, we shouldn't need these other overrides. https://github.com/celery/celery/blob/v4.4.7/celery/fixups/django.py https://docs.celeryproject.org/en/v4.4.7/django/first-steps-with-django.html#using-celery-with-django
e77cfb5 to
c21c172
Compare
|
Removed the config setting entirely as suggested. |
| import os | ||
|
|
||
| from celery import Celery | ||
| from django.conf import settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't comment on the actual line, but probably change the default value for DJANGO_SETTINGS_MODULE in here too?
|
Your PR has finished running tests. There were no failures. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/deploy_to_stage |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/deploy_to_stage |
|
EdX Release Notice: This PR has been deployed to the production environment. |
|
Hi @feanil -- I'm running latest master on one of my sandboxes, but it's throwing Is there something I need to do to ensure these tasks are auto-discovered by celery? |
|
@pomegranited edX is actively still working on more things in this space, right now we're forking Celery to dig into what's going on here and to add better logging. The current theory is that import failures during Celery's autodiscovery are being swallowed by celery. We'll hopefully know more in the next week or two. |
|
Thanks for the information @feanil ! I've started watching for PRs against https://github.com/edx/celery, plus https://github.com/edx/edx-platform/pull/25699 and https://github.com/edx/edx-platform/pull/25698 |
| # Celery's task autodiscovery won't find tasks nested in a tasks package. | ||
| # Tasks are only registered when the module they are defined in is imported. | ||
| CELERY_IMPORTS = ( | ||
| 'poll.tasks', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @feanil , edX has gotten reports that XBlock-poll's reporting features are no longer working (TNL-8370), and I think it was caused by this change (but went unnoticed for months?).
The issue is that the poll XBlock is not a django app, so its tasks.py won't get auto-discovered by celery. If so, is it OK if I fix it with a PR here to reinstate CELERY_IMPORTS = ('poll.tasks', ), or is there some other way I should be doing that now?
Previous PR: https://github.com/edx/edx-platform/pull/23700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Braden, that seems like a fine fix, the other option would be to make the polls code into a django app? Which I would prefer but either is acceptable.
…feature is not working [TNL-8370] [MNG-2273] [BB-4877] ## Description This is a backport of https://github.com/edx/edx-platform/pull/28019 to the Lilac master branch, as [requested](https://github.com/edx/edx-platform/pull/28019#issuecomment-952413371) by @alfredchavez. Summary: > xblock-poll's celery task was broken, then fixed in #23700, then broken again by #25479. This fixes it again. ## Supporting information See original PR. ## Testing instructions See original PR. ## Deadline None ## Other information .
Update the celery startup code to more closely match the docs. We believe some of these imports are causeing circulare
dependencies that are causing race conditions in task discovery. Since all django apps should be loaded using the
django fixup in celery 4, we shouldn't need these other overrides.
https://github.com/celery/celery/blob/v4.4.7/celery/fixups/django.py
https://docs.celeryproject.org/en/v4.4.7/django/first-steps-with-django.html#using-celery-with-django