Skip to content

Commit 961b2f3

Browse files
David BouchareStephenSorriaux
authored andcommitted
feat(core): closed states instead of lost states (#573)
In order to be better in sync with the official documentation (https://zookeeper.apache.org/doc/r3.5.5/zookeeperProgrammers.html#ch_zkSessions) it is better to rename those variables to `close` instead of `lost`.
1 parent ded7946 commit 961b2f3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

kazoo/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
string_types = six.string_types
6969
bytes_types = (six.binary_type,)
7070

71-
LOST_STATES = (KeeperState.EXPIRED_SESSION, KeeperState.AUTH_FAILED,
71+
CLOSED_STATES = (KeeperState.EXPIRED_SESSION, KeeperState.AUTH_FAILED,
7272
KeeperState.CLOSED)
7373
ENVI_VERSION = re.compile(r'([\d\.]*).*', re.DOTALL)
7474
ENVI_VERSION_KEY = 'zookeeper.version'
@@ -513,14 +513,14 @@ def _session_callback(self, state):
513513

514514
# Note that we don't check self.state == LOST since that's also
515515
# the client's initial state
516-
dead_state = self._state in LOST_STATES
516+
closed_state = self._state in CLOSED_STATES
517517
self._state = state
518518

519519
# If we were previously closed or had an expired session, and
520520
# are now connecting, don't bother with the rest of the
521521
# transitions since they only apply after
522522
# we've established a connection
523-
if dead_state and state == KeeperState.CONNECTING:
523+
if closed_state and state == KeeperState.CONNECTING:
524524
self.logger.log(BLATHER, "Skipping state change")
525525
return
526526

@@ -529,8 +529,8 @@ def _session_callback(self, state):
529529
"state: %s", state)
530530
self._live.set()
531531
self._make_state_change(KazooState.CONNECTED)
532-
elif state in LOST_STATES:
533-
self.logger.info("Zookeeper session lost, state: %s", state)
532+
elif state in CLOSED_STATES:
533+
self.logger.info("Zookeeper session closed, state: %s", state)
534534
self._live.clear()
535535
self._make_state_change(KazooState.LOST)
536536
self._notify_pending(state)

0 commit comments

Comments
 (0)