celery-progress icon indicating copy to clipboard operation
celery-progress copied to clipboard

Incompatible with django_celery_results

Open aidin-leo opened this issue 5 years ago • 1 comments

Websocket breaks when using django celery results because of django ORM.

aidin-leo avatar Jan 08 '21 15:01 aidin-leo

This can be fixed by adding sync_to_async decorator to progress.get_info() or for compatibility to oldest version receive method can be updated to:

async def receive(self, text_data):
    text_data_json = json.loads(text_data)
    task_type = text_data_json['type']

    if task_type == 'check_task_completion':
        from asgiref.sync import sync_to_async
        await self.channel_layer.group_send(
            self.task_id,
            {
                'type': 'update_task_progress',
                'data': await sync_to_async(Progress(AsyncResult(self.task_id)).get_info, thread_sensitive=True)()
            }
        )

aidin-leo avatar Jan 08 '21 15:01 aidin-leo