1
0
Fork 0

re-implement cancellation

This commit is contained in:
Sean Sube 2023-02-26 14:36:32 -06:00
parent 584dddb5d6
commit d1961afdbc
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
1 changed files with 13 additions and 2 deletions

View File

@ -82,11 +82,22 @@ class DevicePoolExecutor:
the future and never execute it. If the job has been started, it
should be cancelled on the next progress callback.
"""
raise NotImplementedError()
if key not in self.jobs:
logger.warn("attempting to cancel unknown job: %s", key)
return False
device = self.jobs[key]
cancel = self.context[device].cancel
logger.info("cancelling job %s on device %s", key, device)
if cancel.get_lock():
cancel.value = True
return True
def done(self, key: str) -> Tuple[Optional[bool], int]:
if key not in self.jobs:
logger.warn("checking status for unknown key: %s", key)
logger.warn("checking status for unknown job: %s", key)
return (None, 0)
device = self.jobs[key]