-
Notifications
You must be signed in to change notification settings - Fork 811
Add Celery task for cleantokens #1070
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
Add Celery task for cleantokens #1070
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1070 +/- ##
==========================================
- Coverage 96.87% 96.59% -0.28%
==========================================
Files 31 32 +1
Lines 1759 1764 +5
==========================================
Hits 1704 1704
- Misses 55 60 +5
Continue to review full report at Codecov.
|
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, this is cool. Is there a way to provide some test coverage of this?
Sure there is. But it requires to run Celery alongside the test suite. I don't think it is worth adding that complexity to the test suite, given that the test would ensure nothing more that a simple function call calls a function, and Celery can run Python code (which is hopefully tested in Celery itself). |
Can this functionality be accommodated external to DOT such as in your Django app? I'm not sure we should be adding code that's not core DOT functionality here. |
Can this functionality be accommodated external to DOT such as in your Django app? I'm not sure we should be adding code that's not core DOT functionality here.
Sure it can. As can the management command – that is just the same thing, only that it is called from the command line.
It's nice to have things that make sense to be run periodically pop up in django-admin automatically. Tasks are reusable by design.
|
@Natureshadow I'm trying to understand what to expect with Celery. Is the defined task supposed to show up in Django Admin? What additional configuration is needed to make this happen in, for example, https://github.com/n2ygk/dot-tutorial? I made a few changes but am missing something fundamental I think. Do some templates need to be added oauth2_provider? |
I'm trying to understand what to expect with Celery. Is the defined task supposed to show up in Django Admin?
Depends on how the project orchestrates tasks. Most will probably resort to using django-celery-beat.
What additional configuration is needed to make this happen in, for example, https://github.com/n2ygk/dot-tutorial?
I made a few changes but am missing something fundamental I think. Do some templates need to be added oauth2_provider?
I will look into that tomorrow.
|
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.
if the defined scheduled task's to be shown in admin might need to use django-celery-beat & django-celery-results to be used/configured to specific project. [I actively maintain both but more work need to be done before deciding to add celery as dependency]
I'm looking for specific configuration changes to my test DOT app so that I can see the celery tasks in the admin console. |
Hi @Natureshadow, just checking in to see if you've had time to look at this. |
I checked what we did in AlekSIS for this, and it seems the steps laid out in the Celery documentation are sufficient. |
@Natureshadow I finally had time to try this out. I basically followed the instructions at:
And see the admin interface and was able to autodiscover the task. I didn't get it completely working (econnrefused) but close enough to understand what I needed to. Please rebase this PR and I'll merge it. Thanks. |
a689741
to
2d96223
Compare
2d96223
to
af39ed1
Compare
Done! |
…lery and conflicts with Huey.
…lery and conflicts with Huey.
…lery and conflicts with Huey.
…lery and conflicts with Huey.
* Revert #1070: tasks.py raises an import exception with Celery and conflicts with Huey.
* Revert #1070: tasks.py raises an import exception with Celery and conflicts with Huey. * bump version to 1.7.1
Description of the Change
This adds a Celery task to clean expired tokens. It can be used to schedule token cleanup in the background, for applications using Celery and Celery beat.
The
tasks
module is autodiscovered in projects that use Celery, and should not be loaded in other projects, so this does not introduce any new dependency,Checklist
CHANGELOG.md
updated (only for user relevant changes)AUTHORS