Commit 49fadeb1 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Set try/except block at the lowest level as possible.

- Avoid have a 'break' at the first level and the end of the 'wile True'
- Set try/except block around the only location where the exception can be raised.
- Reduce indentation
- Clarify that the loop purpose is to restart when an exception is raised.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1507 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 968cd132
......@@ -142,24 +142,26 @@ class Application(object):
# since down or broken nodes may be already repaired.
node.setRunning()
try:
while True:
while True:
# handle new connected masters
for node in self.nm.getMasterList():
if node.isRunning():
self.unconnected_master_node_set.add(node.getAddress())
# handle new connected masters
for node in self.nm.getMasterList():
if node.isRunning():
self.unconnected_master_node_set.add(node.getAddress())
# start the election process
self.primary = None
self.primary_master_node = None
# start the election process
self.primary = None
self.primary_master_node = None
try:
self._doElection(bootstrap)
except ElectionFailure, m:
# something goes wrong, clean then restart
self._electionFailed(m)
bootstrap = False
else:
# election succeed, stop the process
self.primary = self.primary is None
break
except ElectionFailure, m:
# something goes wrong, clean then restart
self._electionFailed(m)
bootstrap = False
def _doElection(self, bootstrap):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment