I would like to set "errored" to False if the exception is a Timeout error. I'm a little confused how try except flows work in python here (and surprisingly couldn't find any doc clarifying this - if anyone has one regarding how the blocks are executed please feel free to link), like if multiple exception blocks are true, do they all execute? Or just the first one? I assume the below doesn't work because we don't have access to 'r'
try:
r = request(
method="POST",
...
)
r.raise_for_status()
resp = r.json()
errored = False
except Exception as e:
resp = _parse_json(e)
errored = True
if r.Timeout:
errored = False
And the below is the effect I want, just not sure if it works as intended with the try/except flow
try:
r = request(
...
)
r.raise_for_status()
resp = r.json()
errored = False
except Exception as e:
resp = _parse_json(e)
errored = True
except r.Timeout:
errored = False
This is my first time handling/making post requests so please bear with me!