Skip to content

Commit

Permalink
client: catch invalid timeout value
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Jun 22, 2021
1 parent 7976eee commit a2004de
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,11 +1307,13 @@ def download_contributions(
ndownloads = 0

for name, values in all_ids.items():
timeout -= time.perf_counter() - start
if timeout < 1:
return ndownloads
if timeout > 0:
timeout -= time.perf_counter() - start
if timeout < 1:
return ndownloads

start = time.perf_counter()

start = time.perf_counter()
cids = list(values["ids"])
paths, per_page = self._download_resource(
resource="contributions", ids=cids, fmt=fmt,
Expand All @@ -1326,11 +1328,13 @@ def download_contributions(
print(f"No new contributions to download for '{name}'.")

for component in components:
timeout -= time.perf_counter() - start
if timeout < 1:
return ndownloads
if timeout > 0:
timeout -= time.perf_counter() - start
if timeout < 1:
return ndownloads

start = time.perf_counter()

start = time.perf_counter()
ids = list(values[component]["ids"])
paths, per_page = self._download_resource(
resource=component, ids=ids, fmt=fmt,
Expand Down

0 comments on commit a2004de

Please sign in to comment.