Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with django_celery_results #73

Open
aidin-leo opened this issue Jan 8, 2021 · 1 comment · May be fixed by #74
Open

Incompatible with django_celery_results #73

aidin-leo opened this issue Jan 8, 2021 · 1 comment · May be fixed by #74

Comments

@aidin-leo
Copy link

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

@aidin-leo
Copy link
Author

aidin-leo commented Jan 8, 2021

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)()
            }
        )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant