3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-12 16:28:17 +00:00

Merge pull request #181 from jix/monotonic

Use monotonic clock for timeouts
This commit is contained in:
Jannis Harder 2022-06-15 16:27:23 +02:00 committed by GitHub
commit c944a9c99c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,7 @@ if os.name == "posix":
import subprocess import subprocess
from shutil import copyfile, copytree, rmtree from shutil import copyfile, copytree, rmtree
from select import select from select import select
from time import time, localtime, sleep, strftime from time import monotonic, localtime, sleep, strftime
from sby_design import SbyProperty, SbyModule, design_hierarchy from sby_design import SbyProperty, SbyModule, design_hierarchy
all_procs_running = [] all_procs_running = []
@ -349,7 +349,7 @@ class SbyTask(SbyConfig):
self.procs_running = [] self.procs_running = []
self.procs_pending = [] self.procs_pending = []
self.start_clock_time = time() self.start_clock_time = monotonic()
if os.name == "posix": if os.name == "posix":
ru = resource.getrusage(resource.RUSAGE_CHILDREN) ru = resource.getrusage(resource.RUSAGE_CHILDREN)
@ -392,7 +392,7 @@ class SbyTask(SbyConfig):
proc.poll() proc.poll()
if self.opt_timeout is not None: if self.opt_timeout is not None:
total_clock_time = int(time() - self.start_clock_time) total_clock_time = int(monotonic() - self.start_clock_time)
if total_clock_time > self.opt_timeout: if total_clock_time > self.opt_timeout:
self.log(f"Reached TIMEOUT ({self.opt_timeout} seconds). Terminating all subprocesses.") self.log(f"Reached TIMEOUT ({self.opt_timeout} seconds). Terminating all subprocesses.")
self.status = "TIMEOUT" self.status = "TIMEOUT"
@ -734,7 +734,7 @@ class SbyTask(SbyConfig):
self.taskloop() self.taskloop()
total_clock_time = int(time() - self.start_clock_time) total_clock_time = int(monotonic() - self.start_clock_time)
if os.name == "posix": if os.name == "posix":
ru = resource.getrusage(resource.RUSAGE_CHILDREN) ru = resource.getrusage(resource.RUSAGE_CHILDREN)