from queue import SimpleQueue
from types import FrameType
from typing import ClassVar

from gunicorn.app.base import BaseApplication
from gunicorn.config import Config
from gunicorn.dirty import DirtyArbiter
from gunicorn.glogging import Logger as GLogger
from gunicorn.sock import BaseSocket
from gunicorn.workers.base import Worker

from ._types import _AddressType
from .pidfile import Pidfile

class Arbiter:
    WORKER_BOOT_ERROR: ClassVar[int]
    APP_LOAD_ERROR: ClassVar[int]
    START_CTX: ClassVar[dict[int | str, str | list[str]]]
    LISTENERS: ClassVar[list[BaseSocket]]
    WORKERS: ClassVar[dict[int, Worker]]
    WAKEUP_REQUEST: ClassVar[int]
    SIGNALS: ClassVar[list[int]]
    SIG_NAMES: ClassVar[dict[int, str]]
    log: GLogger | None
    SIG_QUEUE: SimpleQueue[int]
    pidfile: Pidfile | None
    systemd: bool
    worker_age: int
    reexec_pid: int
    master_pid: int
    master_name: str
    dirty_arbiter_pid: int
    dirty_arbiter: DirtyArbiter | None
    dirty_pidfile: str | None
    pid: int
    app: BaseApplication
    cfg: Config
    worker_class: type[Worker]
    address: list[_AddressType]
    timeout: int
    proc_name: str
    num_workers: int

    def __init__(self, app: BaseApplication) -> None: ...
    def setup(self, app: BaseApplication) -> None: ...
    def start(self) -> None: ...
    def init_signals(self) -> None: ...
    def signal(self, sig: int, frame: FrameType | None) -> None: ...
    def run(self) -> None: ...
    def signal_chld(self, sig: int, frame: FrameType | None) -> None: ...
    def handle_chld(self) -> None: ...
    handle_cld = handle_chld
    def handle_hup(self) -> None: ...
    def handle_term(self) -> None: ...
    def handle_int(self) -> None: ...
    def handle_quit(self) -> None: ...
    def handle_ttin(self) -> None: ...
    def handle_ttou(self) -> None: ...
    def handle_usr1(self) -> None: ...
    def handle_usr2(self) -> None: ...
    def handle_winch(self) -> None: ...
    def maybe_promote_master(self) -> None: ...
    def wakeup(self) -> None: ...
    def halt(self, reason: str | None = None, exit_status: int = 0) -> None: ...
    def wait_for_signals(self, timeout: float | None = 1.0) -> list[int]: ...
    def stop(self, graceful: bool = True) -> None: ...
    def reexec(self) -> None: ...
    def reload(self) -> None: ...
    def murder_workers(self) -> None: ...
    def reap_workers(self) -> None: ...
    def manage_workers(self) -> None: ...
    def spawn_worker(self) -> int: ...
    def spawn_workers(self) -> None: ...
    def kill_workers(self, sig: int) -> None: ...
    def kill_worker(self, pid: int, sig: int) -> None: ...
    def spawn_dirty_arbiter(self) -> int | None: ...
    def kill_dirty_arbiter(self, sig: int) -> None: ...
    def reap_dirty_arbiter(self) -> None: ...
    def manage_dirty_arbiter(self) -> None: ...
