INNER CODE UNIT · Python

_OwnedHTTPServer

mars-tw/anti-gambling-trader-tw · core/ui/server.py:132

class _OwnedHTTPServer(ThreadingHTTPServer):
    allow_reuse_address = False
    # Handler threads are deliberately non-daemon: request work must finish or
    # be explicitly interrupted by this server's own socket lifecycle.
    daemon_threads = False
    # ThreadingMixIn's default server_close() joins indefinitely.  We own a
    # bounded registry below instead, so a slow-drip client cannot make local
    # shutdown wait forever before it can close its socket.
    block_on_close = False
    request_queue_size = 16

    def __init__(self, *args: Any, **kwargs: Any) -> None:
        super().__init__(*args, **kwargs)
        self._owned_lock = threading.RLock()
        self._owned_closing = False
        self._owned_connections: dict[int, Any] = {}
        self._owned_handler_threads: dict[int, threading.Thread] = {}
        self._owned_request_deadlines: dict[int, tuple[int, threading.Timer]] = {}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…