From: Christian Heller Date: Sun, 22 Feb 2015 13:00:23 +0000 (+0100) Subject: Server/py: Improve server instance conflict management. X-Git-Tag: tce~491 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7B%20web_path%20%7D%7D/decks/test.html?a=commitdiff_plain;h=17580e7df8f2110c0edf563a4f895a05b8fc417c;p=plomrogue Server/py: Improve server instance conflict management. --- diff --git a/plomrogue-server.py b/plomrogue-server.py index eb6ace2..986732f 100755 --- a/plomrogue-server.py +++ b/plomrogue-server.py @@ -45,7 +45,8 @@ def cleanup_server_io(io_db): def helper(file_key, path_key): if file_key in io_db: io_db[file_key].close() - if not io_db["kicked_by_rival"]: + if not io_db["kicked_by_rival"] \ + and os.access(io_db[path_key], os.F_OK): os.remove(io_db[path_key]) helper("file_out", "path_out") helper("file_in", "path_in") @@ -64,6 +65,7 @@ def detect_atomic_leftover(path, tmp_suffix): def obey(cmd, io_db, prefix): """""" + server_test(io_db) print("input " + prefix + ": " + cmd) try: tokens = shlex.split(cmd, comments=True) @@ -139,7 +141,7 @@ def server_test(io_db): raise SystemExit(msg) -def io_loop (): +def io_loop(): return False @@ -161,11 +163,9 @@ try: prefix = "record file line " line_n = 1 while world_db["turn"] < opts.replay: - server_test(io_db) obey(file.readline().rstrip(), io_db, prefix + str(line_n)) line_n = line_n + 1 while io_loop(): - server_test(io_db) obey(file.readline().rstrip(), io_db, prefix + str(line_n)) line_n = line_n + 1 file.close()