Skip to content

Commit fd0526d

Browse files
committed
As @andre-merzky points out, there is no need to raise an exception here,
since returning fulfills the contract of `cancel()` equally well AND makes it easier to invoke `cancel()` correctly.
1 parent 3712b16 commit fd0526d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/psij/job.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,10 @@ def cancel(self) -> None:
154154
155155
:raises psij.SubmitException: if the job has not yet been submitted.
156156
"""
157+
if self.status.final:
158+
return
157159
if not self.executor:
158160
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')
163161
else:
164162
self.executor.cancel(self)
165163

0 commit comments

Comments
 (0)