Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recover from the HTTP error in #507 (with fallback). #594

Merged
merged 1 commit into from
May 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/uproot/source/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ def task(resource):
if not multipart_supported:
resource.handle_no_multipart(source, ranges, futures, results)
else:
resource.handle_multipart(source, futures, results, response)
resource.handle_multipart(
source, futures, results, response, ranges
)

except Exception:
excinfo = sys.exc_info()
Expand Down Expand Up @@ -384,7 +386,7 @@ def handle_no_multipart(self, source, ranges, futures, results):
results[chunk.start, chunk.stop] = chunk.raw_data
futures[chunk.start, chunk.stop]._run(self)

def handle_multipart(self, source, futures, results, response):
def handle_multipart(self, source, futures, results, response, ranges):
"""
Helper function for :ref:`uproot.source.http.HTTPResource.multifuture`
to handle the multipart GET response.
Expand All @@ -394,17 +396,15 @@ def handle_multipart(self, source, futures, results, response):
else:
response_buffer = _ResponseBuffer(response)

original_futures = dict(futures)

num_found = 0
while len(futures) > 0:
range_string, size = self.next_header(response_buffer)
if range_string is None:
raise OSError(
"""found {} of {} expected headers in HTTP multipart
for URL {}""".format(
num_found, len(futures), self._file_path
)
)
num_found += 1
if range_string is None:
self.handle_no_multipart(source, ranges, original_futures, results)
return

start, last = range_string.split(b"-")
start, last = int(start), int(last)
Expand Down