Add terminate selected tasks action in admin#449
Add terminate selected tasks action in admin#449caoqianming wants to merge 7 commits intocelery:mainfrom
Conversation
auvipy
left a comment
There was a problem hiding this comment.
can you please elaborate the change a bit more? can you also verify the change?
|
When a long task is in running state, I may need to terminate it for various reasons. So adding this action in admin is useful. I added the code and tested it and it works fine. In the beginning I was terminating tasks one by one in a for loop, later I realized that I could pass in a list, so I made some changes. |
auvipy
left a comment
There was a problem hiding this comment.
can you add tests to verify this? and do not introduce any regression?
|
Okay, I'll try. |
|
@caoqianming unittests are run using install a virtualenv with the test dependencies, make sure you are on python 3.11: This requires a postgres database to be available on Currently there are no tests testing the admin pages since there was very little functionality there, so you'll have to add a test_admin.py yourself. |
|
Hello. I add some test @AllexVeldman |
There was a problem hiding this comment.
Pull Request Overview
This PR adds a new action to the Django admin interface allowing administrators to terminate selected tasks, along with corresponding unit tests.
- Introduces terminate_task action in TaskResultAdmin which terminates tasks and reports success or error messages.
- Adds unit tests in t/unit/test_admin.py covering both successful termination and failure scenarios.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| t/unit/test_admin.py | Adds tests for the new terminate_task action |
| django_celery_results/admin.py | Implements the terminate_task action in the admin |
Comments suppressed due to low confidence (1)
t/unit/test_admin.py:27
- [nitpick] The variable name 'id' shadows the built-in function id(). Consider renaming it to 'task_id' or similar to avoid potential confusion.
id = uuid()
|
I am going to deeply consider it again, may be by the end of this month. |
auvipy
left a comment
There was a problem hiding this comment.
can you please fix the merge conflict on test file?
for more information, see https://pre-commit.ci

No description provided.