Skip to content

Commit

Permalink
Shelled popen was not implementing neither the timelimit nor the moni…
Browse files Browse the repository at this point in the history
…toring
  • Loading branch information
jmfernandez committed Aug 25, 2023
1 parent 18d82b1 commit 60fd77c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cwltool/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,26 @@ def terminate(): # type: () -> None
if sproc.stdin is not None:
sproc.stdin.close()

tm = None
if timelimit is not None and timelimit > 0:

def terminate(): # type: () -> None
try:
_logger.warning(

Check warning on line 1046 in cwltool/job.py

View check run for this annotation

Codecov / codecov/patch

cwltool/job.py#L1044-L1046

Added lines #L1044 - L1046 were not covered by tests
"[job %s] exceeded time limit of %d seconds and will be terminated",
name,
timelimit,
)
sproc.terminate()
except OSError:
pass

Check warning on line 1053 in cwltool/job.py

View check run for this annotation

Codecov / codecov/patch

cwltool/job.py#L1051-L1053

Added lines #L1051 - L1053 were not covered by tests

tm = Timer(timelimit, terminate)
tm.daemon = True
tm.start()

Check warning on line 1057 in cwltool/job.py

View check run for this annotation

Codecov / codecov/patch

cwltool/job.py#L1055-L1057

Added lines #L1055 - L1057 were not covered by tests
if monitor_function:
monitor_function(sproc)

rcode = sproc.wait()

return rcode
Expand Down

0 comments on commit 60fd77c

Please sign in to comment.