mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-11-17 11:21:29 +00:00
Fix: keep Celery's Django task base for file move scoped tasks
Passing task_cls to Celery replaces the Django fixup's default DjangoTask, so FileMoveScopedTask, built on the plain Task, left every task without delay_on_commit. The workflow AI suggestions trigger failed with an AttributeError. FileMoveScopedTask now subclasses DjangoTask, which only needs django.db.transaction and is safe to import before apps load. The task scope test also asserts tasks are DjangoTask instances.
This commit is contained in:
1 parent
4822744a79
commit
ab7a4e4280
2 files changed
+8
-2
No files matched your search
@@ -9,6 +9,7 @@ from typing import TYPE_CHECKING
|
||||
import pytest
|
||||
from asgiref.sync import async_to_sync
|
||||
from asgiref.sync import sync_to_async
|
||||
from celery.contrib.django.task import DjangoTask
|
||||
from django.db import transaction
|
||||
from django.http import HttpRequest
|
||||
from django.http import HttpResponse
|
||||
@@ -777,10 +778,12 @@ class TestCeleryTaskScope:
|
||||
- A registered task is inspected
|
||||
THEN:
|
||||
- It runs through FileMoveScopedTask
|
||||
- It keeps Celery's DjangoTask API, such as delay_on_commit
|
||||
"""
|
||||
from paperless.celery import FileMoveScopedTask
|
||||
|
||||
assert isinstance(bulk_update_documents, FileMoveScopedTask)
|
||||
assert isinstance(bulk_update_documents, DjangoTask)
|
||||
|
||||
def test_failing_task_still_moves_committed_change(
|
||||
self,
|
||||
|
||||
Reference in new issue
Block a user