@@ -327,6 +327,7 @@ def stderr_stdout_log_path(
327
327
env = env ,
328
328
cwd = self .outdir ,
329
329
make_job_dir = lambda : runtimeContext .create_outdir (),
330
+ kill_switch = runtimeContext .kill_switch ,
330
331
job_script_contents = job_script_contents ,
331
332
timelimit = self .timelimit ,
332
333
name = self .name ,
@@ -492,8 +493,8 @@ def prepare_environment(
492
493
# Set on ourselves
493
494
self .environment = env
494
495
495
- def process_monitor (self , sproc : "subprocess.Popen[str]" ) -> None :
496
- """Watch a process, logging its max memory usage."""
496
+ def process_monitor (self , sproc : "subprocess.Popen[str]" , kill_switch : threading . Event ) -> None :
497
+ """Watch a process, logging its max memory usage or terminating it if kill_switch is activated ."""
497
498
monitor = psutil .Process (sproc .pid )
498
499
# Value must be list rather than integer to utilise pass-by-reference in python
499
500
memory_usage : MutableSequence [Optional [int ]] = [None ]
@@ -835,6 +836,7 @@ def docker_monitor(
835
836
cleanup_cidfile : bool ,
836
837
docker_exe : str ,
837
838
process : "subprocess.Popen[str]" ,
839
+ kill_switch : threading .Event ,
838
840
) -> None :
839
841
"""Record memory usage of the running Docker container."""
840
842
# Todo: consider switching to `docker create` / `docker start`
@@ -911,6 +913,7 @@ def _job_popen(
911
913
env : Mapping [str , str ],
912
914
cwd : str ,
913
915
make_job_dir : Callable [[], str ],
916
+ kill_switch : threading .Event ,
914
917
job_script_contents : Optional [str ] = None ,
915
918
timelimit : Optional [int ] = None ,
916
919
name : Optional [str ] = None ,
0 commit comments