run-llama/liteparse · error · ValueError
pool_size must be >= 1
Error message
pool_size must be >= 1
What it means
WorkerPool is a fixed-size pool of subprocess parsers; constructing it with pool_size less than 1 would create a pool that can never serve a parse, so __init__ raises ValueError immediately before spawning workers. It is a constructor-time argument validation, not a runtime failure.
Solutions
- Pass an integer pool_size >= 1 when constructing WorkerPool
- Clamp computed values: pool_size = max(1, computed_size)
- If a config/env var feeds pool_size, validate/parse it before construction (e.g. int(os.environ.get('PARSE_POOL_SIZE', '2')))
- Wrap construction in try/except ValueError to surface a clear configuration error at startup
Example fix
# before
pool = WorkerPool(config, pool_size=int(os.environ.get('PARSE_POOL_SIZE', 0)))
# after
pool_size = max(1, int(os.environ.get('PARSE_POOL_SIZE', '2')))
pool = WorkerPool(config, pool_size=pool_size) Defensive patterns
Strategy: validation
Validate before calling
pool_size = int(raw_pool_size)
if pool_size < 1:
raise ValueError(f'pool_size must be >= 1, got {pool_size}') Type guard
def is_valid_pool_size(v: object) -> bool:
return isinstance(v, int) and not isinstance(v, bool) and v >= 1 Try / catch
try:
pool = WorkerPool(config, pool_size=pool_size)
except ValueError as e:
raise ConfigError(f'invalid liteparse pool configuration: {e}') from e Prevention
- Never compute pool_size from possibly-empty collections; use max(1, n)
- Give env/config-driven sizes a safe default (e.g. 2) and clamp with max(1, value)
- Validate all pool settings at application startup, not lazily
- Exclude bool from int coercion (True == 1) when parsing config
When it happens
Trigger: Calling WorkerPool(config, pool_size=0), a negative value, or a pool_size computed from something like len(items) on an empty collection, or an environment/config value like PARSE_POOL_SIZE that is unset-interpreted as 0.
Common situations: Config-driven pool sizing where an env var defaults to 0; computing pool_size as cpu_count-derived or len(batch)-based value that evaluates to 0 in tests or single-item scripts; typo passing pool_size=0 intentionally to 'disable' the pool.
Related errors
- parse_timeout must be > 0 seconds
- parse_timeout requires pool_size
- poolSize must be an integer >= 1
- File not found
- parseTimeoutMs requires poolSize
AI-assisted analysis of run-llama/liteparse@22d2dd8cd7 (2026-09-08).
Data as JSON: /api/errors/20fcaca4d43bc562.
Report an issue: GitHub.
Appendix: source
Thrown at packages/python/liteparse/_pool.py:204
for stream in (self._proc.stdin, self._proc.stdout):
try:
if stream:
stream.close()
except OSError:
pass
class WorkerPool:
"""Fixed-size pool of parse worker processes with a hard kill deadline."""
def __init__(
self,
config: Dict[str, Any],
pool_size: int,
parse_timeout: Optional[float] = None,
):
if pool_size < 1:
raise ValueError("pool_size must be >= 1")
if parse_timeout is not None and parse_timeout <= 0:
raise ValueError("parse_timeout must be > 0 seconds")
self._config = dict(config)
self._timeout = parse_timeout
self._idle: "queue.Queue[_Worker]" = queue.Queue()
self._lock = threading.Lock()
self._workers: List[_Worker] = []
self._closed = False
# Spawn eagerly: children import and construct their native parsers
# concurrently while the caller goes on with its own startup.
for _ in range(pool_size):
self._spawn_worker()
def _spawn_worker(self) -> None:
worker = _Worker(self._config)
with self._lock:
self._workers.append(worker)
self._idle.put(worker)View on GitHub (pinned to 22d2dd8cd7)