Merge pull request #690 from tcely/patch-3

Let Tasks expire correctly
This commit is contained in:
meeb authored and GitHub committed 2025-02-16 13:00:13 +11:00
commit dd55ed5fe5
3 files changed
+462

No files matched your search

+12
View File
@@ -760,6 +760,18 @@ class TasksView(ListView):
queryset = self.get_queryset()
now = timezone.now()
for task in queryset:
# There was broken logic in `Task.objects.locked()`, work around it.
# With that broken logic, the tasks never resume properly.
# This check unlocks the tasks without a running process.
# `task.locked_by_pid_running()` returns:
# - `True`: locked and PID exists
# - `False`: locked and PID does not exist
# - `None`: not `locked_by`, so there was no PID to check
if task.locked_by_pid_running() is False:
task.locked_by = None
# do not wait for the task to expire
task.locked_at = None
task.save()
obj, url = map_task_to_instance(task)
if not obj:
# Orphaned task, ignore it (it will be deleted when it fires)