-
-
Notifications
You must be signed in to change notification settings - Fork 806
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
Does Django Channels enforce single-threaded per connection execution? #2133
Comments
Hi. Individual ASGI events are dispatched serially — see #1933 for a potential change there — but you're (correctly!) using You're also using |
What I want is to handle the receive calls simultaneously. With this what i mean is that the time between the receive calls should be of one second approx, but it seems that the consumer is only able to handle one receive call at a time. What i want is to shrink the time between the receive calls to one second. Is this somehow possible? |
As long as your You could override dispatch to check that your
|
I dont understand what you meant with the last answer. When I try the code you proposed I get the error |
i will try to fix this issue. kindly assign this issue to me |
Have you been able to solve the issue or have you done any advance on the issue? |
I have created an application that receives audio every second from a websocket connection and I would like to process the audio in parallel. However, the consumers receive function seems single-threaded. What I mean is that even if I send audio every second the audio processing needs more than 2 seconds and this delays everything. I am using the AsyncWebsocketConsumer consumer class. In the code below I have simulated the audio processing with a 2 second sleep so that you can try i out. I am executing django with daphne (
daphne -b 0.0.0.0 -p 8000 proiektua.asgi:application
)consumers.py
Logs:
127.0.0.1:43476 - - [06/Feb/2025:09:34:51] "WSCONNECT /ws/chat/1/" - -
Time between receive: 1.0896313190460205
Time between receive: 2.002781391143799
Time between receive: 2.003610134124756
Time between receive: 2.0032858848571777
Time between receive: 2.0033938884735107
Time between receive: 2.0036416053771973
Time between receive: 2.0029494762420654
Time between receive: 2.003593921661377
Time between receive: 2.0041894912719727
127.0.0.1:43476 - - [06/Feb/2025:09:35:08] "WSDISCONNECT /ws/chat/1/" - -
I have tried with asyncio create_task but it doens't work how I want. I would appreciate any help, thanks in advance.
The text was updated successfully, but these errors were encountered: