Commit c1c5e475 authored by Vincent Pelletier's avatar Vincent Pelletier

Prepare code simplification: conditionally reconnect to primary master.

This does not change code flow:
- self.master_node is None when entering the loop for the first time
- there is no way to restart the loop other than a PrimaryFailure exception

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1686 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 0f46f63d
...@@ -140,8 +140,9 @@ class Application(object): ...@@ -140,8 +140,9 @@ class Application(object):
# start the operation. This cycle will be executed permentnly, # start the operation. This cycle will be executed permentnly,
# until the user explicitly requests a shutdown. # until the user explicitly requests a shutdown.
while True: while True:
# look for the primary master if self.master_node is None:
self.connectToPrimary() # look for the primary master
self.connectToPrimary()
self.operational = False self.operational = False
try: try:
while True: while True:
...@@ -162,6 +163,7 @@ class Application(object): ...@@ -162,6 +163,7 @@ class Application(object):
except PrimaryFailure, msg: except PrimaryFailure, msg:
logging.error('primary master is down: %s', msg) logging.error('primary master is down: %s', msg)
self.master_node = None
def connectToPrimary(self): def connectToPrimary(self):
"""Find a primary master node, and connect to it. """Find a primary master node, and connect to it.
......
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