Skip to content

Commit

Permalink
feat(core): closed states instead of lost states (#573)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
David Bouchare authored and StephenSorriaux committed Oct 4, 2019
1 parent ded7946 commit 961b2f3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions kazoo/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
string_types = six.string_types
bytes_types = (six.binary_type,)

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

# Note that we don't check self.state == LOST since that's also
# the client's initial state
dead_state = self._state in LOST_STATES
closed_state = self._state in CLOSED_STATES
self._state = state

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

Expand All @@ -529,8 +529,8 @@ def _session_callback(self, state):
"state: %s", state)
self._live.set()
self._make_state_change(KazooState.CONNECTED)
elif state in LOST_STATES:
self.logger.info("Zookeeper session lost, state: %s", state)
elif state in CLOSED_STATES:
self.logger.info("Zookeeper session closed, state: %s", state)
self._live.clear()
self._make_state_change(KazooState.LOST)
self._notify_pending(state)
Expand Down

0 comments on commit 961b2f3

Please sign in to comment.