Skip to content

Commit ab12c10

Browse files
committed
Hotfix support for django_db for celery backend (specially for django_celery_results)
1 parent a762315 commit ab12c10

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

celery_progress/backend.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from abc import ABCMeta, abstractmethod
33
from decimal import Decimal
44

5-
from celery.result import EagerResult, allow_join_result
5+
from asgiref.sync import sync_to_async
66
from celery.backends.base import DisabledBackend
7-
7+
from celery.result import EagerResult, allow_join_result
88

99
PROGRESS_STATE = 'PROGRESS'
1010

@@ -57,6 +57,7 @@ def __init__(self, result):
5757
"""
5858
self.result = result
5959

60+
@sync_to_async
6061
def get_info(self):
6162
response = {'state': self.result.state}
6263
if self.result.state in ['SUCCESS', 'FAILURE']:

celery_progress/websockets/consumers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def receive(self, text_data):
3131
self.task_id,
3232
{
3333
'type': 'update_task_progress',
34-
'data': Progress(AsyncResult(self.task_id)).get_info()
34+
'data': await Progress(AsyncResult(self.task_id)).get_info()
3535
}
3636
)
3737

0 commit comments

Comments
 (0)