Skip to content

Commit 2fb93a8

Browse files
committed
fix(core): Revert "Fix possible endless wait in stop() after AUTH_FAILED error (#688)"
This reverts commit 5225b3e. The commit being reverted here caused kazoo not to empty the send queue before disconnecting. This means that if a client submitted asynchronous requests and then called client.stop(), the connection would be closed immediately, usually after only one (but possibly more) of the submitted requests were sent. Prior to this, Kazoo would empty the queue of submitted requests all the way up to and including the Close request when client.stop() was called. Another area where this caused problems is in a busy multi-threaded system. One thread might decide to gracefully close the connection, but if there is any traffic generated by another thread, then the connection would end up terminating without ever sending the Close request. Failure to gracefully shutdown a ZooKeeper connection can mean that other system components need to wait for ephemeral node timeouts to detect that a component has shutdown.
1 parent b4155ea commit 2fb93a8

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

kazoo/protocol/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def _connect_attempt(self, host, hostip, port, retry):
619619
self.ping_outstanding.clear()
620620
last_send = time.monotonic()
621621
with self._socket_error_handling():
622-
while not self.client._stopped.is_set():
622+
while True:
623623
# Watch for something to read or send
624624
jitter_time = random.randint(1, 40) / 100.0
625625
deadline = last_send + read_timeout / 2.0 - jitter_time

kazoo/tests/test_client.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ def test_async_auth_failure(self):
258258
with pytest.raises(AuthFailedError):
259259
client.add_auth("unknown-scheme", digest_auth)
260260

261-
client.stop()
262-
263261
def test_add_auth_on_reconnect(self):
264262
client = self._get_client()
265263
client.start()

0 commit comments

Comments
 (0)