{"record":{"id":"439252b23de69c4f","repo":"unclecode/crawl4ai","slug":"termios-tty-select-modules-not-available-on-this-p","errorCode":null,"errorMessage":"termios/tty/select modules not available on this platform","messagePattern":"termios/tty/select modules not available on this platform","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"warning","filePath":"crawl4ai/browser_profiler.py","lineNumber":259,"sourceCode":"                    return\n                \n                # Small delay to prevent busy waiting\n                await asyncio.sleep(0.1)\n                \n            except Exception as e:\n                self.logger.warning(f\"Error in Windows keyboard listener: {e}\", tag=tag)\n                # Continue trying instead of failing completely\n                await asyncio.sleep(0.1)\n                continue\n    \n    async def _listen_unix(self, user_done_event: asyncio.Event, check_browser_process, tag: str):\n        \"\"\"Unix/Linux/macOS keyboard listener using termios and select.\"\"\"\n        try:\n            import termios\n            import tty\n            import select\n        except ImportError:\n            raise ImportError(\"termios/tty/select modules not available on this platform\")\n        \n        # Get stdin file descriptor\n        try:\n            fd = sys.stdin.fileno()\n        except (AttributeError, OSError):\n            raise ImportError(\"stdin is not a terminal\")\n        \n        # Save original terminal settings\n        old_settings = None\n        try:\n            old_settings = termios.tcgetattr(fd)\n        except termios.error as e:\n            raise ImportError(f\"Cannot get terminal attributes: {e}\")\n        \n        try:\n            # Switch to non-canonical mode (cbreak mode)\n            tty.setcbreak(fd)\n            ","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/unclecode/crawl4ai/blob/7e801521428ee12509994d39151006f64055ebe3/crawl4ai/browser_profiler.py#L241-L277","documentation":"BrowserProfiler._listen_unix imports termios/tty/select and converts ImportError into this message. On Unix-likes these are stdlib and virtually always present; failure indicates a non-Unix platform (Windows) or a stripped Python build (termios excluded), i.e. the Unix listener was invoked where it cannot run.","triggerScenarios":"Calling _listen_unix() on Windows; a minimal/embedded Python build compiled without termios; unusual environments like some WASM/pyodide runtimes that lack termios.","commonSituations":"Cross-platform code calling the private listener without a platform check; exotic Python distributions; test harnesses invoking internals on the wrong OS.","solutions":["Use the profiler's public interactive method which dispatches per OS.","Gate manual calls: choose _listen_windows when sys.platform == 'win32'.","On stripped Python builds, install a full CPython interpreter."],"exampleFix":"# before\nawait profiler._listen_unix(event, check_proc, 'PROFILE')  # on Windows -> ImportError\n\n# after\nimport sys\nlistener = profiler._listen_windows if sys.platform == 'win32' else profiler._listen_unix\nawait listener(event, check_proc, 'PROFILE')","handlingStrategy":"validation","validationCode":"import sys\nif sys.platform == 'win32':\n    raise OSError('Unix keyboard listener requires a Unix-like platform')","typeGuard":"import sys\ndef is_unix() -> bool:\n    return sys.platform != 'win32'","tryCatchPattern":null,"preventionTips":["Let the profiler dispatch the listener per OS.","Gate manual calls with sys.platform checks."],"tags":["browser-profiler","unix","platform-specific"],"backgroundTag":null,"analyzedSha":"7e801521428ee12509994d39151006f64055ebe3","analyzedAt":"2026-08-14T20:46:20.673Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}