stream_with_context and unhandled exceptions #5318
Unanswered
wrkhenddher
asked this question in
Q&A
Replies: 1 comment
-
Hi, did you find any workaround? I am having the same issue. Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello folks,
Within the context of
@stream_with_context
and this old flask issue, I have a question:Is there any hook or facility to finish streaming content once an exception is raised within the generator?
Our current solution is to wrap the generator with a
try/except
block and yield "Output truncated - Exception..." when an exception is caught.The main problems are:
HTTP/1.0 200 OK
header has been sent but content is truncated due to the exception.Content-Length
header is absent."Output truncated - Exception..."
, there is no way to know there was such error.Perhaps the more fundamental question is:
How should one deal with abrupt terminations within a generator wired to
@stream_with_context
?Bit of extra context:
Beta Was this translation helpful? Give feedback.
All reactions