Skip to content

Commit

Permalink
Refactor fetch_length function to continue fetching if speed is 1 and…
Browse files Browse the repository at this point in the history
… all fields in time are 0
  • Loading branch information
zeroquinc committed Jan 31, 2024
1 parent 8f6dbf3 commit 7bca786
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ def fetch_length(session):
try:
# Return the JSON response from the session's LENGTH_URL
response = session.get(LENGTH_URL).json()
# If the response matches the given structure, continue the loop to fetch again
if response == {'speed': 1, 'time': {'hours': 0, 'milliseconds': 0, 'minutes': 0, 'seconds': 0}, 'totaltime': {'hours': 0, 'milliseconds': 0, 'minutes': 0, 'seconds': 0}}:
# If speed is 1 and all fields in time are 0, continue the loop to fetch again
if response['result']['speed'] == 1 and all(value == 0 for value in response['result']['time'].values()):
logger.debug("Speed is 1 and all fields in time are 0. Continuing the loop to fetch again...")
continue
return response
except requests.exceptions.RequestException as e:
Expand Down

0 comments on commit 7bca786

Please sign in to comment.