In my flask application, I interact with MongoDB. For resilience, I follow a pattern to wrap the insert/update operations in a retry loop like this -
retry =