def safe_mongocall(call):
def _safe_mongocall(*args, **kwargs):<EOL><INDENT>for i in range(<NUM_LIT:4>):<EOL><INDENT>try:<EOL><INDENT>return call(*args, **kwargs)<EOL><DEDENT>except pymongo.errors.AutoReconnect:<EOL><INDENT>print ('<STR_LIT>' % i)<EOL>time.sleep(pow(<NUM_LIT:2>, i))<EOL><DEDENT><DEDENT>return call(*args, **kwargs)<EOL><DEDENT>return _safe_mongocall<EOL>
Decorator for automatic handling of AutoReconnect-exceptions.