Add/document way to stream request without read timeout #2203
Unanswered
flacjacket
asked this question in
Q&A
Replies: 1 comment
-
I'm sorry if this is obvious, but did you try adjusting the timeout parameters? You should be able to adjust read timeouts and connection timeouts independently. https://www.python-httpx.org/advanced/#timeout-configuration |
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
-
The functionality that I'd like to have is to be able to
.stream
a given request and be able to have this raise some exception if the server becomes unavailable. The use case here is streaming event data from a security camera, and because data is only sent when there is an event and there may be arbitrary time that no data is sent, but I'd like to be able to keep the streaming connection open, which is why a read timeout wouldn't be a good solution. However, if the camera goes down, either that it is powered down or loses network connection, I'd like the httpx client to get some exception to start retrying the connection. The current implementation uses aAsyncClient
as an async context manager and.stream("GET", url)
from the camera. There is a non-async implementation usingrequests
that has the right behavior (bysession.mount
'ing arequests.adapters.HTTPAdapter
), but I'm not sure how to do something similar with httpx.See https://github.com/tchellomello/python-amcrest/blob/master/src/amcrest/http.py for reference to the current implementation. This would help to address issues that we are seeing at home-assistant/core#69640
Beta Was this translation helpful? Give feedback.
All reactions