Skip to content

Commit

Permalink
Merge pull request #23 from amazingjxq/fix_delay
Browse files Browse the repository at this point in the history
added reaper delay argument
  • Loading branch information
benoitc committed Aug 30, 2013
2 parents 4581071 + 0d3e711 commit 932d68f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions socketpool/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def __init__(self, factory,
retry_max=3, retry_delay=.1,
timeout=-1, max_lifetime=600.,
max_size=10, options=None,
reap_connections=True, backend="thread"):
reap_connections=True, reap_delay=1,
backend="thread"):

if isinstance(backend, str):
self.backend_mod = load_backend(backend)
Expand Down Expand Up @@ -75,6 +76,7 @@ def __init__(self, factory,

self._reaper = None
if reap_connections:
self.reap_delay = reap_delay
self.start_reaper()

def too_old(self, conn):
Expand All @@ -94,7 +96,7 @@ def murder_connections(self):

def start_reaper(self):
self._reaper = self.backend_mod.ConnectionReaper(self,
delay=self.max_lifetime)
delay=self.reap_delay)
self._reaper.ensure_started()

def _reap_connection(self, conn):
Expand Down Expand Up @@ -197,4 +199,3 @@ def connection(self, **options):
conn.handle_exception(e)
finally:
self.release_connection(conn)

0 comments on commit 932d68f

Please sign in to comment.