Commit db818a64 by Michael Cetrulo

use Python's logging

parent 22912847
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
import time import time
import pymongo import pymongo
import logging
logger = logging.getLogger(__name__)
def get_methods(*objs): def get_methods(*objs):
return set( return set(
attr attr
...@@ -25,7 +28,7 @@ def safe_mongocall(call): ...@@ -25,7 +28,7 @@ def safe_mongocall(call):
try: try:
return call(*args, **kwargs) return call(*args, **kwargs)
except pymongo.errors.AutoReconnect: except pymongo.errors.AutoReconnect:
print 'AutoReconnecting, try %d' % i logger.warning('AutoReconnecting, try %d' % i)
time.sleep(pow(2, i)) time.sleep(pow(2, i))
# Try one more time, but this time, if it fails, let the # Try one more time, but this time, if it fails, let the
# exception bubble up to the caller. # exception bubble up to the caller.
......
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