Open bblanchon opened 4 years ago
It is not an infinite loop.
Django creates separate thread that generates response.
On Ctrl+C
it shutdowns main thread, but process is waiting for other threads.
If you really need to stop it - press Ctrl+C
one more time and it will stop it.
Hi @wowkin2,
Thanks for this answer.
I pressed Ctrl-C
a dozen times, but the server won't stop.
Yesterday I saw the same problem on Docker on macOS, so I don't think it's related to Windows.
Django creates separate thread that generates response.
I'm really puzzled by this sentence. The whole point of async views is to reduce the number of threads, right? Or, as I put it in the [SO question]:
implement an SSE view without monopolizing a thread per client
Best regards, Benoit
@bblanchon then you need to understand if you want to utilize async or fix StreamHttpResponse. If first - then you need another solution.
Describe what is the purpose of SSE in your case or what you want to achive? Because goal to
implement an SSE view without monopolizing a thread per client looks like you want to push something from time to time to Frontend, and not reply with big file (main purpose of
StreamingHttpResponse
)
I'm sorry @wowkin2, I didn't realize there could be any ambiguity here. SSE is for sending events from the server to the client; I never said I wanted to send large responses.
As I mentioned in the question, I used StreamingHttpResponse
because it was successfully used for SSE in this other SO question, the only problem is that it uses a synchronous view.
@bblanchon "send large responses"
is one of purposes of StreamingHttpResponse
.
And as I don't know how you are using it right now, I can't suggest the best async solution for you. Perhaps Django Channels is completely enough for you.
Hi,
As soon as someone gets
/sse_async
, the Daphne process enters an infinite loop and cannot be stopped withCtrl-C
.Tested with:
Best regards, Benoit