3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-05 22:14:08 +00:00

SbyProc: New error_callback instead of exit_callback for failing procs

This commit is contained in:
Jannis Harder 2022-06-15 12:10:52 +02:00
parent f131fe5b8f
commit e99884e319

View file

@ -87,6 +87,7 @@ class SbyProc:
self.output_callback = None
self.exit_callback = None
self.error_callback = None
def register_dep(self, next_proc):
if self.finished:
@ -115,6 +116,14 @@ class SbyProc:
if self.exit_callback is not None:
self.exit_callback(retcode)
def handle_error(self, retcode):
if self.terminated:
return
if self.logfile is not None:
self.logfile.close()
if self.error_callback is not None:
self.error_callback(retcode)
def terminate(self, timeout=False):
if self.task.opt_wait and not timeout:
return
@ -185,20 +194,22 @@ class SbyProc:
self.task.status = "ERROR"
if not self.silent:
self.task.log(f"{self.info}: COMMAND NOT FOUND. ERROR.")
self.handle_error(self.p.returncode)
self.terminated = True
self.task.terminate()
return
self.handle_exit(self.p.returncode)
if self.checkretcode and self.p.returncode != 0:
self.task.status = "ERROR"
if not self.silent:
self.task.log(f"{self.info}: task failed. ERROR.")
self.handle_error(self.p.returncode)
self.terminated = True
self.task.terminate()
return
self.handle_exit(self.p.returncode)
self.finished = True
for next_proc in self.notify:
next_proc.poll()
@ -503,14 +514,15 @@ class SbyTask(SbyConfig):
proc.checkretcode = True
def instance_hierarchy_callback(retcode):
if retcode != 0:
self.precise_prop_status = False
return
if self.design_hierarchy == None:
with open(f"{self.workdir}/model/design.json") as f:
self.design_hierarchy = design_hierarchy(f)
def instance_hierarchy_error_callback(retcode):
self.precise_prop_status = False
proc.exit_callback = instance_hierarchy_callback
proc.error_callback = instance_hierarchy_error_callback
return [proc]