Allow multiple tasks in an async consumer to run in parallel #1838
Unanswered
nils-van-zuijlen
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a use case for which I'd like to have multiple tasks in a single consumer instance run concurrently.
Here is a sample code that would only work if the consumer can simultaneously run multiple tasks
The idea of this sample is that a message in this consumer's channel would cause
task_foo
to run, usingsend_call
to run a procedure on the connected client, and thatsend_call
only returns once an answer was received.However, due to the way tasks are scheduled in https://github.com/django/channels/blob/main/channels/utils.py#L51, it runs into a deadlock as
send_call
waits forreceive_json
to be called, but that will never happen because a task is currently running in that consumer.I tried replacing the
await_many_dispatch
function by the following code, and my deadlock went away. Would it possible to enable multi-tasking in async consumers?Beta Was this translation helpful? Give feedback.
All reactions