https://github.com/rholder/retrying
raise AutoReconnect("connection closed")
from pymongo.errors import AutoReconnect
def retry_if_auto_reconnect_error(exception):
"""Return True if we should retry (in this case when it's an AutoReconnect), False otherwise"""
return isinstance(exception, AutoReconnect)
@retry(retry_on_exception=retry_if_auto_reconnect_error, stop_max_attempt_number=2, wait_fixed=2000)
def insert(self, insert_dict):
pass