Skip to content

Commit 3712b16

Browse files
committed
Check if the job is in a final state before attempting to ask the executor
to cancel it.
1 parent 1d9bdd8 commit 3712b16

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/psij/job.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def cancel(self) -> None:
156156
"""
157157
if not self.executor:
158158
raise SubmitException('Cannot cancel job: not bound to an executor.')
159+
elif self.status.final:
160+
# TODO: we probably need a different type of exception for this and the above case,
161+
# TODO: but this is probably a spec issue
162+
raise SubmitException('Cannot cancel a job in a final state')
159163
else:
160164
self.executor.cancel(self)
161165

0 commit comments

Comments
 (0)