spawn_tor: catch OSError and wrap as ClanError

This commit is contained in:
Jörg Thalheim
2025-08-26 12:12:29 +02:00
parent c45d4cfec9
commit e6066a6cb1

View File

@@ -43,6 +43,7 @@ def spawn_tor() -> Iterator[None]:
cmd_args = ["tor", "--HardwareAccel", "1"]
packages = ["tor"]
cmd = nix_shell(packages, cmd_args)
try:
process = Popen(cmd)
try:
while not is_tor_running():
@@ -55,6 +56,9 @@ def spawn_tor() -> Iterator[None]:
process.terminate()
process.wait()
log.info("Tor process terminated")
except OSError as e:
msg = f"Failed to spawn tor process with command: {cmd}"
raise ClanError(msg) from e
@dataclass(frozen=True)