33 lines
No EOL
786 B
Python
33 lines
No EOL
786 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from collections.abc import Callable
|
|
from multiprocessing.context import Process
|
|
from typing import Any, Tuple
|
|
|
|
|
|
def _child_process_entrypoint(
|
|
worker: Callable[..., Any],
|
|
worker_args: Tuple[Any, ...],
|
|
) -> None:
|
|
"""Configure the child environment and run the worker."""
|
|
|
|
# These are popped in the sub-process.
|
|
os.environ.pop("DEBUG", None)
|
|
os.environ.pop("BAND_AIDER_TERMINAL_UI", None)
|
|
|
|
worker(*worker_args)
|
|
|
|
|
|
def start_worker_process(
|
|
worker: Callable[..., Any],
|
|
worker_args: Tuple[Any, ...],
|
|
) -> Process:
|
|
"""Start one terminal UI worker process."""
|
|
|
|
process = Process(
|
|
target=_child_process_entrypoint,
|
|
args=(worker, worker_args),
|
|
)
|
|
process.start()
|
|
return process |