Commit a4cc0674 by Jonathan Kamens

Let AutoReconnect exception bubble up to caller after 5 failures

parent 9c2d7673
......@@ -11,13 +11,15 @@ def safe_mongocall(call):
"""
def _safe_mongocall(*args, **kwargs):
for i in xrange(5):
for i in xrange(4):
try:
return call(*args, **kwargs)
except pymongo.errors.AutoReconnect:
print 'AutoReconnecting, try', i
time.sleep(pow(2, i))
print 'Error: Failed operation!'
# Try one more time, but this time, if it fails, let the
# exception bubble up to the caller.
return call(*args, **kwargs)
return _safe_mongocall
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment