From eeb1826b0538d0870f356bb31a4be1d61a170fc9 Mon Sep 17 00:00:00 2001 From: tcely Date: Mon, 24 Feb 2025 02:45:41 -0500 Subject: [PATCH 1/3] Upgrade to 1.2.8 for Django 5 support. --- Pipfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pipfile b/Pipfile index 00389093..08c20163 100644 --- a/Pipfile +++ b/Pipfile @@ -7,7 +7,7 @@ verify_ssl = true autopep8 = "*" [packages] -django = "~=3.2" +django = "*" django-sass-processor = "*" libsass = "*" pillow = "*" @@ -15,7 +15,7 @@ whitenoise = "*" gunicorn = "*" django-compressor = "*" httptools = "*" -django-background-tasks = "==1.2.5" +django-background-tasks = ">=1.2.8" django-basicauth = "*" psycopg2-binary = "*" mysqlclient = "*" From 83203254adf65af7603c8d80483134ce0a6d2d57 Mon Sep 17 00:00:00 2001 From: tcely Date: Mon, 24 Feb 2025 02:47:37 -0500 Subject: [PATCH 2/3] Patched for version 1.2.8 --- patches/background_task/models.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/patches/background_task/models.py b/patches/background_task/models.py index 02f7164a..0e46c5b6 100644 --- a/patches/background_task/models.py +++ b/patches/background_task/models.py @@ -6,8 +6,8 @@ import logging import os import traceback -from compat import StringIO -from compat.models import GenericForeignKey +from io import StringIO +from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models import Q @@ -50,14 +50,15 @@ class TaskManager(models.Manager): if queue: qs = qs.filter(queue=queue) ready = qs.filter(run_at__lte=now, failed_at=None) - _priority_ordering = '{}priority'.format(app_settings.BACKGROUND_TASK_PRIORITY_ORDERING) + _priority_ordering = '{}priority'.format( + app_settings.BACKGROUND_TASK_PRIORITY_ORDERING) ready = ready.order_by(_priority_ordering, 'run_at') if app_settings.BACKGROUND_TASK_RUN_ASYNC: currently_failed = self.failed().count() currently_locked = self.locked(now).count() count = app_settings.BACKGROUND_TASK_ASYNC_THREADS - \ - (currently_locked - currently_failed) + (currently_locked - currently_failed) if count > 0: ready = ready[:count] else: @@ -102,7 +103,8 @@ class TaskManager(models.Manager): s = "%s%s" % (task_name, task_params) task_hash = sha1(s.encode('utf-8')).hexdigest() if remove_existing_tasks: - Task.objects.filter(task_hash=task_hash, locked_at__isnull=True).delete() + Task.objects.filter(task_hash=task_hash, + locked_at__isnull=True).delete() return Task(task_name=task_name, task_params=task_params, task_hash=task_hash, @@ -251,13 +253,14 @@ class Task(models.Model): self.failed_at = timezone.now() logger.warning('Marking task %s as failed', self) completed = self.create_completed_task() - task_failed.send(sender=self.__class__, task_id=self.id, completed_task=completed) + task_failed.send(sender=self.__class__, + task_id=self.id, completed_task=completed) self.delete() else: backoff = timedelta(seconds=(self.attempts ** 4) + 5) self.run_at = timezone.now() + backoff logger.warning('Rescheduling task %s for %s later at %s', self, - backoff, self.run_at) + backoff, self.run_at) task_rescheduled.send(sender=self.__class__, task=self) self.locked_by = None self.locked_at = None @@ -330,9 +333,6 @@ class Task(models.Model): db_table = 'background_task' - - - class CompletedTaskQuerySet(models.QuerySet): def created_by(self, creator): @@ -389,7 +389,8 @@ class CompletedTask(models.Model): # when the task should be run run_at = models.DateTimeField(db_index=True) - repeat = models.BigIntegerField(choices=Task.REPEAT_CHOICES, default=Task.NEVER) + repeat = models.BigIntegerField( + choices=Task.REPEAT_CHOICES, default=Task.NEVER) repeat_until = models.DateTimeField(null=True, blank=True) # the "name" of the queue this is to be run on From ce68ba9a01e77367c3eb24ddfa16e78b5ba71162 Mon Sep 17 00:00:00 2001 From: tcely Date: Mon, 24 Feb 2025 02:51:36 -0500 Subject: [PATCH 3/3] Drop Python 3.7 as unsupported --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index faf25319..c1450eae 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] steps: - uses: actions/checkout@v4 - name: Install Python ${{ matrix.python-version }}