Closed
Description
Right now I do this:
def get_mp3_stream():
if STREAMING_URL.startswith("http:") or STREAMING_URL.startswith("https:"):
return requests.get(STREAMING_URL, headers={"connection": "close"}).socket
return open(STREAMING_URL, "rb")
but
- the socket property is not documented and not in standard
requests
- this has no way of properly releasing the socket at the ConnectionManager level
The real requests library has a public raw
property that calling code may use when the request includes stream=True
. So simply renaming the socket
property to raw
would be one step in the right direction. (the stream argument is already supported in adafruit_requests)
#: File-like object representation of response (for advanced usage).
#: Use of ``raw`` requires that ``stream=True`` be set on the request.
#: This requirement does not apply for use internally to Requests.
self.raw = None
As for properly releasing the socket, I guess I need to restructure my code so it can hold onto the requests object as long as needed.
Metadata
Metadata
Assignees
Labels
No labels