From 3e48f9b637a23b7588d20ef8fd69621ee3c718cd Mon Sep 17 00:00:00 2001 From: John Demme Date: Fri, 12 Nov 2021 22:57:43 +0000 Subject: [PATCH] [ESI] cosim-runner: fix race in getting the port Fixes #1985. --- tools/esi/esi-cosim-runner.py.in | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/esi/esi-cosim-runner.py.in b/tools/esi/esi-cosim-runner.py.in index 4d33daea1d..c843496cc0 100755 --- a/tools/esi/esi-cosim-runner.py.in +++ b/tools/esi/esi-cosim-runner.py.in @@ -177,12 +177,14 @@ class CosimTestRunner: checkCount += 1 if checkCount > 200: raise Exception(f"Cosim never wrote cfg file: {portFileName}") - portFile = open(portFileName, "r") - for line in portFile.readlines(): - m = re.match("port: (\\d+)", line) - if m is not None: - port = int(m.group(1)) - portFile.close() + port = -1 + while port < 0: + portFile = open(portFileName, "r") + for line in portFile.readlines(): + m = re.match("port: (\\d+)", line) + if m is not None: + port = int(m.group(1)) + portFile.close() # Wait for the simulation to start accepting RPC connections. checkCount = 0