Skip to content

Commit 2509106

Browse files
authored
Merge pull request #251 from tcely/patch-3
Patch the logic in `locked()`
2 parents b0786b7 + 1530b6b commit 2509106

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ RUN set -x && \
367367
# Copy root
368368
COPY config/root /
369369

370+
# patch background_task
371+
ADD https://github.com/tcely/django-background-tasks/raw/refs/heads/locked-logic-fix/background_task/models.py /usr/local/lib/python3.11/dist-packages/background_task/models.py
372+
370373
# Create a healthcheck
371374
HEALTHCHECK --interval=1m --timeout=10s --start-period=3m CMD ["/app/healthcheck.py", "http://127.0.0.1:8080/healthcheck"]
372375

tubesync/sync/views.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,11 @@ def get_context_data(self, *args, **kwargs):
824824
queryset = self.get_queryset()
825825
now = timezone.now()
826826
for task in queryset:
827+
# There is broken logic in Task.objects.locked(), work around it.
828+
# Without this, the queue never resumes properly.
829+
if task.locked_by and not task.locked_by_pid_running():
830+
task.locked_by = None
831+
task.save()
827832
obj, url = map_task_to_instance(task)
828833
if not obj:
829834
# Orphaned task, ignore it (it will be deleted when it fires)

0 commit comments

Comments
 (0)