Skip to content
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

Allow Celery 5 by using shared_task #82

Merged
merged 3 commits into from
Jan 18, 2022
Merged

Conversation

bgrant
Copy link
Collaborator

@bgrant bgrant commented Jan 6, 2022

Replacing celery.task.task with celery.shared_task seems to fix the tests
on Celery 5 (they continue to work with Celery 4 as well).

I don't know enough about Celery to be sure this is the right fix, but
I'm going off of this:

If you’re using Django (see First steps with Django), or you’re the
author of a library then you probably want to use the shared_task()
decorator:

https://docs.celeryproject.org/en/stable/userguide/tasks.html

First steps with Django — Celery 5.2.3 documentation

@bgrant bgrant requested review from dshafer and demianbrecht January 6, 2022 18:42
@bgrant
Copy link
Collaborator Author

bgrant commented Jan 6, 2022

Fixes #80

@@ -1,5 +1,5 @@
Django~=2.2.0
celery>=4.0.2,<=4.4.0,!=4.1.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why 4.1.0 was excluded? I'd imagine that we ran into an issue with it at some point.

Copy link
Collaborator Author

@bgrant bgrant Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the exclusion back 👍

@@ -7,7 +7,7 @@

import logging
from pydoc import locate
from celery.task import task as celery_task
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks shared_task has been around for ages. Curious as to why it wasn't originally used.

@smholloway smholloway merged commit dfc9742 into main Jan 18, 2022
@smholloway smholloway deleted the chore/upgrade-to-celery-5 branch January 18, 2022 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants