Skip to content

Commit 8aef454

Browse files
committed
Emit warning if ping socket select takes longer
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.
1 parent b2f7a46 commit 8aef454

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kazoo/protocol/connection.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,17 @@ def _connect_attempt(self, host, hostip, port, retry):
589589
# Ensure our timeout is positive
590590
timeout = max([read_timeout / 2.0 - jitter_time,
591591
jitter_time])
592+
select_start_time = time.time()
592593
s = self.handler.select([self._socket, self._read_sock],
593594
[], [], timeout)[0]
594595

595596
if not s:
597+
select_block_time = time.time() - select_start_time
598+
if select_block_time > read_timeout:
599+
self.logger.warning(
600+
"Socket select took longer than expected: %0.5f",
601+
select_block_time
602+
)
596603
if self.ping_outstanding.is_set():
597604
self.ping_outstanding.clear()
598605
raise ConnectionDropped(

0 commit comments

Comments
 (0)