Skip to content

Commit

Permalink
Emit warning if ping socket select takes longer
Browse files Browse the repository at this point in the history
We experienced Zookeeper session timeouts within our applications
with Kazoo because of GIL contention blocking the Kazoo thread and
its ping loop. The thread will now emit a warning in such a case.
  • Loading branch information
jarus committed Dec 8, 2020
1 parent b2f7a46 commit 8aef454
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions kazoo/protocol/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,17 @@ def _connect_attempt(self, host, hostip, port, retry):
# Ensure our timeout is positive
timeout = max([read_timeout / 2.0 - jitter_time,
jitter_time])
select_start_time = time.time()
s = self.handler.select([self._socket, self._read_sock],
[], [], timeout)[0]

if not s:
select_block_time = time.time() - select_start_time
if select_block_time > read_timeout:
self.logger.warning(
"Socket select took longer than expected: %0.5f",
select_block_time
)
if self.ping_outstanding.is_set():
self.ping_outstanding.clear()
raise ConnectionDropped(
Expand Down

0 comments on commit 8aef454

Please sign in to comment.