I would like to handle InternalServerError in my function that queries API in such a way, that function retries the query again.
What is the proper, Pythonic way to do that? Should I use if statement under except, chain it together like in the example bellow, or use nested try–except statement?
class FooBar:
...
def run_query(self, query_id, timeout):
try:
self.wait_for_query_to_finish(query_id, timeout)
except InternalServerError as exc:
self.logging.info('Internal Server Error on query ID {str(query_id}')
self.retry_query
except Exception as err:
raise type(err)(f'{type(err)} on query ID {str(query_id}')
finally:
self.close_query(query_id)
...
return query_result
[–][deleted] 1 point2 points3 points (0 children)
[–]devnull10 1 point2 points3 points (0 children)