INNER CODE UNIT · Python

wait_for_handlers

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

    def wait_for_handlers(self, timeout: float) -> bool:
        """Join only this server's workers, and never without a deadline."""

        # Monotonic time keeps this independent of wall-clock changes.
        import time

        until = time.monotonic() + max(0.0, float(timeout))
        current = threading.current_thread()
        with self._owned_lock:
            workers = [
                worker
                for worker in self._owned_handler_threads.values()
                if worker is not current
            ]
        for worker in workers:
            remaining = until - time.monotonic()
            if remaining <= 0:
                break

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…