Skip to content

Commit

Permalink
rename supervisor to reaper
Browse files Browse the repository at this point in the history
  • Loading branch information
karmacoma-eth committed Oct 30, 2024
1 parent bd8f293 commit fb0ded4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/jsi/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Less common options:
--output DIRECTORY directory where solver output files will be written
--supervisor run a supervisor process to avoid orphaned subprocesses
--reaper run a reaper process that kills orphaned solvers when jsi exits
--debug enable debug logging
--csv print solver results in CSV format (<output>/<input>.csv)
--perf print performance timers
Expand Down Expand Up @@ -207,8 +207,8 @@ def parse_args(args: list[str]) -> Config:
config.model = True
case "--csv":
config.csv = True
case "--supervisor":
config.supervisor = True
case "--reaper":
config.reaper = True
case "--daemon":
config.daemon = True
case "--timeout":
Expand Down Expand Up @@ -346,8 +346,8 @@ def main(args: list[str] | None = None) -> int:
controller.start()
status.start()

if config.supervisor:
from jsi.supervisor import Supervisor
if config.reaper:
from jsi.reaper import Reaper

# wait for the subprocesses to start, we need the PIDs for the supervisor
while controller.task.status.value < TaskStatus.RUNNING.value:
Expand All @@ -356,9 +356,9 @@ def main(args: list[str] | None = None) -> int:
# start a supervisor process in daemon mode so that it does not block
# the program from exiting
child_pids = [command.pid for command in controller.commands]
sv = Supervisor(os.getpid(), child_pids, config.debug)
sv.daemon = True
sv.start()
reaper = Reaper(os.getpid(), child_pids, config.debug)
reaper.daemon = True
reaper.start()

# wait for the solvers to finish
controller.join()
Expand Down
4 changes: 2 additions & 2 deletions src/jsi/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(
debug: bool = False,
input_file: str | None = None,
output_dir: str | None = None,
supervisor: bool = False,
reaper: bool = False,
sequence: Sequence[str] | None = None,
model: bool = False,
csv: bool = False,
Expand All @@ -36,7 +36,7 @@ def __init__(
self.debug = debug
self.input_file = input_file
self.output_dir = output_dir
self.supervisor = supervisor
self.reaper = reaper
self.sequence = sequence
self.model = model
self.csv = csv
Expand Down
6 changes: 3 additions & 3 deletions src/jsi/supervisor.py → src/jsi/reaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from jsi.utils import LogLevel, get_console, kill_process, logger, pid_exists


class Supervisor(multiprocessing.Process):
"""Supervisor process that monitors the parent process and its children."""
class Reaper(multiprocessing.Process):
"""Reaper process that monitors the parent process and its children."""

parent_pid: int
child_pids: list[int]
Expand All @@ -22,7 +22,7 @@ def run(self):
level = LogLevel.DEBUG if self.debug else LogLevel.INFO
logger.enable(console=get_console(sys.stderr), level=level)

logger.info(f"supervisor started (PID: {self.pid})")
logger.info(f"reaper started (PID: {self.pid})")
logger.info(f"watching parent (PID: {self.parent_pid})")
logger.info(f"watching children (PID: {self.child_pids})")

Expand Down

0 comments on commit fb0ded4

Please sign in to comment.