@@ -225,13 +225,13 @@ class ProcessRunner:
225225 MAX_RUNNING = (psutil .cpu_count () or 8 ) - 2 # Number of CPUs, with a couple spares
226226
227227 def __init__ (self ):
228- log (f"Process runner will have a maximum of { ProcessRunner .MAX_RUNNING } processes, and currently sees { global_memory_free ():.3f} GB free." )
229-
230228 self .pending = []
231229 self .running = []
232230 self .first_start = time .time ()
233231 self .debug_count = 0
234232
233+ log (f"Process runner will have a maximum of { ProcessRunner .MAX_RUNNING } processes, and currently sees { self .mem_avail ():.3f} GB free." )
234+
235235 def append (self , proc ):
236236 self .pending .insert (0 , proc )
237237
@@ -244,7 +244,7 @@ def children_used_mem(self):
244244 def mem_avail (self ):
245245 if args .max_mem == 0 :
246246 return global_memory_free ()
247- return max (args .max_mem - self .children_used_mem (), 0 )
247+ return min ( global_memory_free (), max (args .max_mem - self .children_used_mem (), 0 ) )
248248
249249 def poll (self ):
250250 # Kill recently started processes until memory is OK, unless there is just one, then there's no point(?)
@@ -279,9 +279,10 @@ def poll(self):
279279
280280 asyncio .get_running_loop ().call_later (ProcessRunner .POLL_DELAY , lambda : self .poll ())
281281
282- process_runner = ProcessRunner ()
282+ process_runner : ProcessRunner | None = None
283283'''Run a shell command in the global process runner'''
284284async def shell (cmd , expected_memory = 0.0 , timeout = None , debug_slow = None ):
285+ assert process_runner is not None
285286 proc = Process (cmd , expected_memory = expected_memory , timeout = timeout , debug_slow = debug_slow )
286287 process_runner .append (proc )
287288 return await proc .future
@@ -720,6 +721,8 @@ async def explore_mode(by_step: list[list[str]]):
720721 log (f"Skipping proof run for step { step } , since it has just one step" , c = white )
721722
722723async def main ():
724+ global process_runner
725+
723726 def preproc_name (name : str ) -> tuple [int , str ]:
724727 first = name .split ("$" )[1 ][5 :]
725728 assert first .startswith ("Step" )
@@ -738,6 +741,7 @@ def group_by_step(names: list[tuple[int, str]], max=None) -> list[list[str]]:
738741 by_step .append ([])
739742 return by_step
740743
744+ process_runner = ProcessRunner ()
741745 process_runner .start_loop ()
742746
743747 log ("Reading property list" , c = white )
0 commit comments