Skip to content

Commit

Permalink
fix: Use get method when host error object is a dictionary
Browse files Browse the repository at this point in the history
This makes sure to not throw an exception when host.error
is not a dictionary and we can not use .get() method

Signed-off-by: Tibor Dudlák <[email protected]>
  • Loading branch information
Tiboris committed Feb 22, 2023
1 parent fd33d68 commit 06f18d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/mrack/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,11 @@ async def strategy_retry(self, reqs):
out_of_resources = False
for host in error_hosts:
logger.error(f"{log_msg_start} Error: {str(host.error)}")
if host.error.get("code", None) == 500: # 500 = SERVER ERROR
# if host.error is a dictionary and code is 500 = SERVER ERROR
if (
isinstance(host.error, dict)
and host.error.get("code", None) == 500
):
logger.info(
f"{log_msg_start} Provider is out of resources, "
"increasing cooldown time before another retry"
Expand Down

0 comments on commit 06f18d1

Please sign in to comment.