|
1 | 1 | from gettext import gettext as _ |
2 | 2 |
|
3 | | -from django.conf import settings |
4 | 3 | from django.db import transaction |
5 | 4 | from django.db.models import Prefetch |
6 | 5 | from django_filters.rest_framework import filters |
|
43 | 42 | CreatedResourcesFilter, |
44 | 43 | ) |
45 | 44 | from pulpcore.constants import TASK_INCOMPLETE_STATES, TASK_STATES |
46 | | -from pulpcore.tasking.tasks import dispatch |
| 45 | +from pulpcore.tasking.tasks import cancel_task, cancel_task_group, dispatch |
47 | 46 | from pulpcore.app.role_util import get_objects_for_user |
48 | 47 |
|
49 | 48 |
|
@@ -228,16 +227,7 @@ def partial_update(self, request, pk=None, partial=True): |
228 | 227 | serializer.is_valid(raise_exception=True) |
229 | 228 |
|
230 | 229 | task = self.get_object() |
231 | | - |
232 | | - # Call the appropriate cancel_task function based on worker type |
233 | | - if settings.WORKER_TYPE == "redis": |
234 | | - from pulpcore.tasking.redis_tasks import cancel_task |
235 | | - |
236 | | - task = cancel_task(task.pk) |
237 | | - else: |
238 | | - from pulpcore.tasking.tasks import cancel_task |
239 | | - |
240 | | - task = cancel_task(task.pk) |
| 230 | + task = cancel_task(task.pk) |
241 | 231 |
|
242 | 232 | # Check whether task is actually canceled |
243 | 233 | http_status = ( |
@@ -358,15 +348,7 @@ def partial_update(self, request, pk=None, partial=True): |
358 | 348 | ): |
359 | 349 | raise PermissionDenied() |
360 | 350 |
|
361 | | - # Call the appropriate cancel_task_group function based on worker type |
362 | | - if settings.WORKER_TYPE == "redis": |
363 | | - from pulpcore.tasking.redis_tasks import cancel_task_group |
364 | | - |
365 | | - task_group = cancel_task_group(task_group.pk) |
366 | | - else: |
367 | | - from pulpcore.tasking.tasks import cancel_task_group |
368 | | - |
369 | | - task_group = cancel_task_group(task_group.pk) |
| 351 | + task_group = cancel_task_group(task_group.pk) |
370 | 352 | # Check whether task group is actually canceled |
371 | 353 | serializer = TaskGroupSerializer(task_group, context={"request": request}) |
372 | 354 | task_statuses = ( |
|
0 commit comments