Send messages to SSE through tokio::sync::mpsc::channel::<String>(5), but ReceiverStream does not consume the messages. #2810
Unanswered
dialogflowchatbot
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Sorry, I don't understand. What panics, the receiver? Do you have a reason to believe your issue is caused by axum? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Thank you for providing such a great tool.
The problem I'm encountering is:
I created a
Sender
andReceiver
usingtokio::sync::mpsc::channel::<String>(5)
, and then I passed theSender
into atokio::spawn
task:completion::completion(&q.robot_id, &q.prompt, sender).await
. The specific code is here: src/ai/crud.rs#L68.This method passes the
Sender
to another functionhuggingface
, and the code is here: src/ai/completion.rs#L40.It is then passed to: src/ai/completion.rs#L91.
Finally, it is passed to: src/ai/llama.rs#L31.
And it is used here: src/ai/llama.rs#L139.
However, the
Receiver
does not consume the messages until the queue is full (5 messages), and then the program panic (intentionally) consumes all 5 messages at once, causing an error.I originally thought the
SSE
configuration might be incorrect, so I wrote a simple push code: src/ai/crud.rs#L67.In this code, the
Receiver
can consume messages normally.It's very strange. Could it be because I passed the
Sender
multiple times?axum version
axum = {version = "0.7", features = ["query", "tokio"]}
Beta Was this translation helpful? Give feedback.
All reactions