This commit is contained in:
Timothee Guerin 2017-07-12 13:23:16 -07:00
Родитель 583eefec79
Коммит 9dc24bd7f6
4 изменённых файлов: 14 добавлений и 10 удалений

5
.vscode/settings.json поставляемый
Просмотреть файл

@ -9,5 +9,6 @@
},
"python.autoComplete.extraPaths": [
"${workspaceRoot}/node"
]
}
],
"python.formatting.autopep8Args": [""]
}

Просмотреть файл

@ -14,7 +14,7 @@ def load_config():
"""
global global_config
if not os.path.isfile(constants.CONFIG_PATH):
raise Exception("Configuration file doesn't exists at %s" % constants.CONFIG_PATH)
raise Exception("Configuration file doesn't exists at {0}".format(constants.CONFIG_PATH))
global_config = configparser.ConfigParser()
global_config.read(constants.CONFIG_PATH)
@ -22,5 +22,5 @@ def load_config():
def get() -> configparser.ConfigParser:
if not global_config:
load_config()
return global_config
return global_config

Просмотреть файл

@ -55,24 +55,25 @@ def find_master(client: batch.BatchServiceClient) -> bool:
# If not dedicated the node cannot be a master
# TODO enable when inter node communication is working with low pri and dedicated together.
# if not config.is_dedicated:
# return False
# return False
for i in range(0, 5):
pool = client.pool.get(config.pool_id)
master = get_master_node_id(pool)
if master:
if master == config.node_id:
print("Node is already the master '%s'" % master)
print("Node is already the master '{0}'".format(master))
return True
else:
print("Pool already has a master '%s'. This node will be a worker" % master)
print("Pool already has a master '{0}'. This node will be a worker".format(master))
return False
else:
print("Pool has no master. Fighting for the throne! (%i/5)" % (i + 1))
print("Pool has no master. Fighting for the throne! ({0}/5)".format(i + 1))
result = try_assign_self_as_master(client, pool)
if result:
print("The battle has been won! Node %s is the new master." % config.node_id)
print("The battle has been won! Node {0} is the new master.".format(config.node_id))
return True
raise CannotAllocateMasterError("Unable to assign node as a master in 5 tries")

2
setup.cfg Normal file
Просмотреть файл

@ -0,0 +1,2 @@
[pep8]
max-line-length = 160