{"record":{"id":"6c658c49db9d34de","repo":"run-llama/liteparse","slug":"parse-timeout-must-be-0-seconds","errorCode":null,"errorMessage":"parse_timeout must be > 0 seconds","messagePattern":"parse_timeout must be > 0 seconds","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/python/liteparse/_pool.py","lineNumber":206,"sourceCode":"                if stream:\n                    stream.close()\n            except OSError:\n                pass\n\n\nclass WorkerPool:\n    \"\"\"Fixed-size pool of parse worker processes with a hard kill deadline.\"\"\"\n\n    def __init__(\n        self,\n        config: Dict[str, Any],\n        pool_size: int,\n        parse_timeout: Optional[float] = None,\n    ):\n        if pool_size < 1:\n            raise ValueError(\"pool_size must be >= 1\")\n        if parse_timeout is not None and parse_timeout <= 0:\n            raise ValueError(\"parse_timeout must be > 0 seconds\")\n        self._config = dict(config)\n        self._timeout = parse_timeout\n        self._idle: \"queue.Queue[_Worker]\" = queue.Queue()\n        self._lock = threading.Lock()\n        self._workers: List[_Worker] = []\n        self._closed = False\n        # Spawn eagerly: children import and construct their native parsers\n        # concurrently while the caller goes on with its own startup.\n        for _ in range(pool_size):\n            self._spawn_worker()\n\n    def _spawn_worker(self) -> None:\n        worker = _Worker(self._config)\n        with self._lock:\n            self._workers.append(worker)\n        self._idle.put(worker)\n\n    def _retire_worker(self, worker: _Worker) -> None:","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/python/liteparse/_pool.py#L188-L224","documentation":"WorkerPool accepts an optional parse_timeout that bounds each parse operation (triggering a hard kill of the worker). A timeout of zero or negative would kill every parse instantly, so __init__ rejects it with ValueError. Pass None to disable the timeout entirely.","triggerScenarios":"Constructing WorkerPool(config, pool_size, parse_timeout=0), a negative float, or a config value that parsed/converted to <= 0 (e.g. milliseconds-vs-seconds unit confusion, or 0 meaning 'no timeout' in the caller's mind).","commonSituations":"Unit conversion mistakes (seconds vs milliseconds) yielding tiny floats; passing 0 intending 'unlimited'; config files where the field exists but is 0 or negative; computing timeout from a user setting defaulting to 0.","solutions":["Pass a positive float (seconds) for parse_timeout, or omit it / pass None to disable","Fix unit conversion so the value is in seconds and > 0 (e.g. ms/1000)","Validate config-derived values before construction: if t is not None and t <= 0: t = None or a sane default","Guard with try/except ValueError at startup to fail fast with a clear config error"],"exampleFix":"# before\npool = WorkerPool(config, pool_size=4, parse_timeout=float(cfg.get('timeout_ms', 0)))\n# after\ntimeout_s = float(cfg.get('timeout_ms', 30000)) / 1000.0\npool = WorkerPool(config, pool_size=4, parse_timeout=timeout_s if timeout_s > 0 else None)","handlingStrategy":"validation","validationCode":"if parse_timeout is not None and parse_timeout <= 0:\n    raise ValueError(f'parse_timeout must be > 0 seconds or None, got {parse_timeout}')","typeGuard":"def is_valid_timeout(v: object) -> bool:\n    return v is None or (isinstance(v, (int, float)) and v > 0)","tryCatchPattern":"try:\n    pool = WorkerPool(config, pool_size=4, parse_timeout=timeout)\nexcept ValueError as e:\n    raise ConfigError(f'invalid liteparse timeout: {e}') from e","preventionTips":["Standardize timeout units as seconds everywhere; convert at the config boundary","Treat 0 as 'unset' and map it to None before construction","Document that None disables the timeout; don't use 0 for that","Validate timeouts where config is loaded, not at pool construction time only"],"tags":["python","configuration","timeout","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}