Skip to content

Commit

Permalink
Issue #36: Correctly set ConnectionHandler.writer_stopped even if an
Browse files Browse the repository at this point in the history
exception is raised inside the writer, like a retry operation failing.
  • Loading branch information
hannosch committed Nov 2, 2012
1 parent 1763ed8 commit 2ecf10e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Bug Handling

- Issue #37: Handle timeout errors during `select` calls on sockets.

- Issue #36: Correctly set `ConnectionHandler.writer_stopped` even if an
exception is raised inside the writer, like a retry operation failing.

0.8 (2012-10-26)
----------------

Expand Down
27 changes: 14 additions & 13 deletions kazoo/protocol/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,19 +395,20 @@ def writer(self):
self.writer_stopped.clear()

retry = self.retry_sleeper.copy()
while not self.client._stopped.is_set():
# If the connect_loop returns False, stop retrying
if self._connect_loop(retry) is False:
break

# Still going, increment our retry then go through the
# list of hosts again
if not self.client._stopped.is_set():
retry.increment()

self.writer_stopped.set()
if self.log_debug:
log.debug('Writer stopped')
try:
while not self.client._stopped.is_set():
# If the connect_loop returns False, stop retrying
if self._connect_loop(retry) is False:
break

# Still going, increment our retry then go through the
# list of hosts again
if not self.client._stopped.is_set():
retry.increment()
finally:
self.writer_stopped.set()
if self.log_debug:
log.debug('Writer stopped')

def _connect_loop(self, retry):
client = self.client
Expand Down

0 comments on commit 2ecf10e

Please sign in to comment.