Logging fixes

This commit is contained in:
Honza Král
2013-11-03 22:39:03 +01:00
parent 9e68ea91ed
commit b8b9f67092
2 changed files with 9 additions and 1 deletions
+8
View File
@@ -1,11 +1,14 @@
import time
import random
import logging
try:
from Queue import PriorityQueue, Empty
except ImportError:
from queue import PriorityQueue, Empty
logger = logging.getLogger('elasticsearch')
class ConnectionSelector(object):
"""
Simple class used to select a connection from a list of currently live
@@ -133,6 +136,10 @@ class ConnectionPool(object):
self.dead_count[connection] = dead_count
timeout = self.dead_timeout * 2 ** min(dead_count - 1, self.timeout_cutoff)
self.dead.put((now + timeout, connection))
logger.warning(
'Connection %r has failed for %i times in a row, putting on %i second timeout.',
connection, dead_count, timeout
)
def mark_live(self, connection):
"""
@@ -175,6 +182,7 @@ class ConnectionPool(object):
# either we were forced or the connection is elligible to be retried
self.connections.append(connection)
logger.info('Resurrecting connection %r (force=%s).', connection, force)
def get_connection(self):
"""