forked from M-Labs/artiq
1
0
Fork 0

Add method to check if termination is requested (#811, #1932)

Co-authored-by: kk105 <kkl@m-kabs.hk>
This commit is contained in:
kk1050 2022-07-07 17:01:34 +08:00 committed by GitHub
parent 46f2842d38
commit 7aa6104872
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

@ -128,6 +128,7 @@ def main():
"scheduler_request_termination": scheduler.request_termination,
"scheduler_get_status": scheduler.get_status,
"scheduler_check_pause": scheduler.check_pause,
"scheduler_check_termination": scheduler.check_termination,
"ccb_issue": ccb_issue,
})
experiment_db.scan_repository_async()

View File

@ -490,3 +490,13 @@ class Scheduler:
return False
return r.priority_key() > run.priority_key()
raise KeyError("RID not found")
def check_termination(self, rid):
"""Returns ``True`` if termination is requested."""
for pipeline in self._pipelines.values():
if rid in pipeline.pool.runs:
run = pipeline.pool.runs[rid]
if run.termination_requested:
return True
return False

View File

@ -111,6 +111,12 @@ class Scheduler:
rid = self.rid
return self._check_pause(rid)
_check_termination = staticmethod(make_parent_action("scheduler_check_termination"))
def check_termination(self, rid=None) -> TBool:
if rid is None:
rid = self.rid
return self._check_termination(rid)
_submit = staticmethod(make_parent_action("scheduler_submit"))
def submit(self, pipeline_name=None, expid=None, priority=None, due_date=None, flush=False):
if pipeline_name is None: