Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions testmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,23 @@ def writeResult():
fp.flush()
os.fsync(fp.fileno())

def writeResultAndExit(exitStatus):
startJob=monotonic()

def writeResultAndExit(exitStatus, useOsExit=False):
writeResult()
print("Calling exit ...")
with open(errFile, 'a+') as fp:
fp.write("[Calling os._exit(%s)]\n" % exitStatus)
if useOsExit:
msg = "[Calling os._exit(%s), Time elapsed: %s]\n"
else:
msg = "[Calling sys.exit(%s), Time elapsed: %s]\n"
fp.write(msg % (exitStatus, monotonic()-startJob))
fp.flush()
sys.stdout.flush()
os._exit(exitStatus)
if useOsExit:
os._exit(exitStatus)
else:
sys.exit(exitStatus)

def sendExpressionTimeout(omc, cmd, timeout):
with open(errFile, 'a+') as fp:
Expand Down Expand Up @@ -98,7 +107,7 @@ def target(res):
pass
with open(errFile, 'a+') as fp:
fp.write("Aborted the command.\n")
writeResultAndExit(0)
writeResultAndExit(0, True)
if res[1] is None:
res[1] = ""
if res[1] is not None:
Expand Down Expand Up @@ -314,7 +323,7 @@ def loadLibraryInNewOM():
execstat["parsing"]=monotonic()-start
with open(errFile, 'a+') as fp:
fp.write("Timeout error for cmd: %s\n%s"%(cmd,str(e)))
writeResultAndExit(0)
writeResultAndExit(0, True)
execstat["parsing"]=monotonic()-start

try:
Expand Down Expand Up @@ -458,7 +467,7 @@ def sendExpressionOldOrNew(cmd):
execstat["build"] = monotonic()-start
with open(errFile, 'a+') as fp:
fp.write(str(e))
writeResultAndExit(0)
writeResultAndExit(0, True)

writeResult()
# Do the simulation
Expand Down Expand Up @@ -508,7 +517,7 @@ def sendExpressionOldOrNew(cmd):
execstat["phase"] = 6
except TimeoutError as e:
execstat["sim"] = monotonic()-start
writeResultAndExit(0)
writeResultAndExit(0, True)

if referenceFile=="":
writeResultAndExit(0)
Expand Down