Skip to content

Instantly share code, notes, and snippets.

@anthonywu
anthonywu / graceful_auto_reconnect.py
Created Jan 29, 2012
Gracefully handle a PyMongo AutoReconnect
View graceful_auto_reconnect.py
import functools
import pymongo
import logging
import time
MAX_AUTO_RECONNECT_ATTEMPTS = 5
def graceful_auto_reconnect(mongo_op_func):
"""Gracefully handle a reconnection event."""
@functools.wraps(mongo_op_func)