Replies: 2 comments
-
I don't think I completely understand, does the stream producing logic run inside the handler or does it run someone else and the handler just passes the messages to the client? Anyway, do I understand it correctly that you have an async task that runs synchronously for several minutes without yielding? You might want to just add periodic |
Beta Was this translation helpful? Give feedback.
-
@mladedav Thanks for so fast response! The mentioned logic runs inside its dedicated tokio task. The periodic I wonder if I could detect the disconnection using Anyway your suggestion seems to solve my issue (though I didn't yet try it), thank you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I know similar questions have been asked here many times, but none of them seem to address the issue I'm facing at the moment.
I have a stream producing logic that performs a lot of work occasionally emitting events via async stream. To cancel it I use a one_shot receiver. It's not good enough for me to cancel it during a next 'yield' moment since it might take a while until a next SSE event is emitted. This async task needs to get a signal at time of disconnection to stop it, not when it decides to emit a next event (might take minutes to get there).
Currently I don't see any way to send this cancellation signal exactly at time when the client has just been disconnected.
axum version
0.8.1
Beta Was this translation helpful? Give feedback.
All reactions