from __future__ import annotations

from collections.abc import Awaitable
from typing import Any, Protocol

class _CommClosedError(Protocol):
    def __call__(self, *args: Any, **kwargs: Any) -> Exception: ...

class Scheduler:
    """Coordinate work across distributed workers."""

    address: str
    loop: Any
    comm_closed_handler: _CommClosedError | None

    def __init__(self, *args: Any, **kwargs: Any) -> None: ...
    async def close(self, fast: bool | None = ...) -> None: ...
    async def finished(self) -> None: ...
    async def start(self, *args: Any, **kwargs: Any) -> None: ...
    def start_http_server(self, *args: Any, **kwargs: Any) -> None: ...
    def add_plugin(self, plugin: Any, name: str | None = ...) -> None: ...
    def call_client_handlers(self, key: str, **kwargs: Any) -> Awaitable[Any]: ...
    def set_comm_closed_handler(self, handler: _CommClosedError | None) -> None: ...

__all__ = ["Scheduler"]
