from __future__ import annotations

import threading


_lock = threading.Lock()
_listen_only_mode = False


def set_listen_only(enabled: bool) -> bool:
    global _listen_only_mode
    with _lock:
        _listen_only_mode = bool(enabled)
        return _listen_only_mode


def is_listen_only() -> bool:
    with _lock:
        return _listen_only_mode

