From f4c700bb6285f280391e5a39be4cdeaa8aeaf812 Mon Sep 17 00:00:00 2001 From: boxofbox Date: Mon, 27 Feb 2023 15:36:56 -0500 Subject: [PATCH] wrapped async_to_sync in closing function --- celery_progress/websockets/backend.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/celery_progress/websockets/backend.py b/celery_progress/websockets/backend.py index 670660b..c8f16c0 100644 --- a/celery_progress/websockets/backend.py +++ b/celery_progress/websockets/backend.py @@ -12,6 +12,9 @@ logger = logging.getLogger(__name__) +async def closing_group_send(channel_layer, channel, message): + await channel_layer.group_send(channel, message) + await channel_layer.close_pools() class WebSocketProgressRecorder(ProgressRecorder): @@ -28,8 +31,9 @@ def __init__(self, *args, **kwargs): @staticmethod def push_update(task_id, data, final=False): try: - async_to_sync(channel_layer.group_send)( - task_id, + async_to_sync(closing_group_send)( + channel_layer, + task_id, {'type': 'update_task_progress', 'data': data} ) except AttributeError: # No channel layer to send to, so ignore it