Skip to content

Commit

Permalink
Merge pull request #107 from boxofbox/master
Browse files Browse the repository at this point in the history
wrapped async_to_sync in closing function
  • Loading branch information
czue authored Mar 2, 2023
2 parents 7ff5b43 + f4c700b commit 961e011
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 961e011

Please sign in to comment.