Counting errors and continue in a loop

I have some python code which is sending several hundred API requests at a time, there can occasionally be HttpError failures with formatting in the individual requests, but I do not want this to stop the whole process.

To enable this I added an exception to my if statement:

def update_conversions(service):

  for req in request_bodies:
    try:
      request = service.conversion().update(body=req)
    except Exception:
      pass

I would like to update this code to get viability of the number or requests that failed, while still continuing the loop, how could I update my code to assign a count of http errors to a variable?



Read more here: https://stackoverflow.com/questions/68487408/counting-errors-and-continue-in-a-loop

Content Attribution

This content was originally published by Ben P at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: