Stream reset on retry #284
Labels
api: storage
Issues related to the googleapis/google-resumable-media-python API.
priority: p2
Moderately-important priority. Fix may not be included in next release.
status: investigating
The issue is under investigation, which is determined to be non-trivial.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Hello there,
I am using the library, indirectly via python-storage, in maybe an unorthodox way: I am trying to implement a download timeout via a custom http adapter and response.
So my response object is throwing pro-actively timeouts (common.InvalidResponse with http.client.REQUEST_TIMEOUT),
which is forcibly triggering the retry logic in the Download class:
google-resumable-media-python/google/resumable_media/requests/download.py
Line 164 in d082772
All goes well, but one thing: the final results content data from both the partial content of prematurely aborted request and the final and complete data of the second request.
It happens because both dataset are accumulated in the
_stream
above.Do you agree it's bug and that on retry the _stream shall be resetted (e.g. seek(0))? Do I miss a use case where it makes sense to accumulated data, or we were just assuming data would be empty anyway on exception?
If I did not miss anything I'll submit a PR to fix it.
Many thanks in advance.
Fred
The text was updated successfully, but these errors were encountered: