Skip to content

Commit

Permalink
wrapped async_to_sync in closing function
Browse files Browse the repository at this point in the history
  • Loading branch information
boxofbox committed Feb 27, 2023
1 parent 7ff5b43 commit f4c700b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions celery_progress/websockets/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand All @@ -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
Expand Down

0 comments on commit f4c700b

Please sign in to comment.