You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@app.get("/stream")
async def stream_data():
headers = {
"Content-Type": "text/plain",
"Transfer-Encoding": "chunked",
"Connection": "keep-alive",
}
def generate():
try:
with httpx.stream(
"GET", config["NODE_API_URL"] + "/testendpoint"
) as r:
for chunk in r.iter_raw():
r.raise_for_status()
yield chunk
except httpx.TimeoutException as e:
print(f"A TimeoutException occurred during dummy streaming {e}")
except httpx.RequestError as e:
print(f"A RequestError occurred during dummy streaming {e}")
except httpx.StreamError as e:
print(f"A StreamError occurred during dummy streaming {e}")
except Exception as e:
print(f"An error occurred during dummy streaming {e}")
return StreamingResponse(generate(), headers=headers)
When I do curl, after 30 seconds, i got this error
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)
But there is error in console, I mean none of print statement is being executed.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi, i am unable to capture error while streaming
Here is my code in fastapi
When I do curl, after 30 seconds, i got this error
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)
But there is error in console, I mean none of print statement is being executed.
Beta Was this translation helpful? Give feedback.
All reactions