Fix major issue with threaded worker keepalive

The keepalive queue management is fixed to not pop extra connections
incorrectly.

Close #816
This commit is contained in:
Randall Leeds 2014-07-12 12:43:32 -07:00
parent f310b04f48
commit ec62d487f7

View File

@ -134,18 +134,17 @@ class ThreadWorker(base.Worker):
now = time.time() now = time.time()
while True: while True:
try: try:
# remove the connection from the queue
conn = self._keep.popleft() conn = self._keep.popleft()
except IndexError: except IndexError:
break break
delta = conn.timeout - now delta = conn.timeout - now
if delta > 0: if delta > 0:
# add the connection back to the queue
self._keep.appendleft(conn) self._keep.appendleft(conn)
break break
else: else:
# remove the connection from the queue
conn = self._keep.popleft()
# remove the socket from the poller # remove the socket from the poller
self.poller.unregister(conn.sock) self.poller.unregister(conn.sock)