Skip to content

API Reference parrot_formdesigner.services.sandbox.pool

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.services.sandbox.pool

View source

Warm asyncio.subprocess worker pool for tiers 1-2 (FEAT-459 / M9).

Implements parrot.eval.sandbox.base.SandboxProvider — the ONLY real pooling implementation in the codebase; NoopSandboxProvider (base.py:259) is a no-op reference, not pooling logic to extend. All sizing knobs are configurable with defaults from spec §7 (OQ-6).

NOTE on network isolation: this module's job is process lifecycle and scheduling, not kernel-level sandboxing. "no network namespace" for tiers 1-2 (spec §2) is an infra/deployment property (e.g. a restricted execution user, seccomp profile, or cgroup) layered UNDER this pool, not something asyncio.subprocess enforces by itself. Tiers 3-4's actual kernel isolation is gVisor (TASK-3170) — this pool is deliberately the CHEAPER, un-containerised path for the two tiers that need no such isolation.

Class ColdStartTimeoutError

Raised when spawning a fresh worker exceeds cold_start_timeout_ms.

Class PoolExhaustedError

Raised by acquire() when no worker becomes available within the queue timeout.

Alias SandboxContext

Re-exported from parrot_formdesigner.core.snippets.SandboxContext.

Alias SandboxOutcome

Re-exported from parrot_formdesigner.core.snippets.SandboxOutcome.

Class SubprocessWorkerPool

Warm-pooled asyncio.subprocess workers for CapabilityTier PURE/HELPERS.

Parameter Type Default Description
tier12_pool_size int 4 Warm workers held per process. Under gunicorn -w N the REAL total is N * this value — size against that, not this number alone (spec §7 note).
recycle_after_invocations int 500 Retire a worker after this many completed invocations.
recycle_after_seconds int 3600 Retire a worker after this much wall time regardless of invocation count.
acquire_queue_timeout_ms int 2000 Maximum time acquire() waits for a worker before raising PoolExhaustedError. NEVER unbounded.
max_queue_depth int 32 Beyond this many queued acquire() callers, fail fast instead of growing the queue.
health_check_interval_s int 30 Interval for the background health sweep that detects poisoned idle workers.
cold_start_timeout_ms int 5000 Maximum time to spawn a fresh worker when the pool is empty and under tier12_pool_size.

Method SubprocessWorkerPool.acquire

Acquire a healthy worker, spawning fresh if the pool has room.

acquire(spec: SandboxSpec) -> Sandbox

Parameter Type Default Description
spec SandboxSpec

Returns: Sandbox

Raises:

  • PoolExhaustedError — no worker became available within acquire_queue_timeout_ms, AND max_queue_depth callers are already waiting.

Method SubprocessWorkerPool.release

Return a worker to the idle queue, or recycle/discard it first.

release(sandbox: Sandbox) -> None

Parameter Type Default Description
sandbox Sandbox

Method SubprocessWorkerPool.start_health_checks

Start the background health check task.

start_health_checks() -> None

Method SubprocessWorkerPool.stop_health_checks

Stop the background health check task.

stop_health_checks() -> None

Method SubprocessWorkerPool.shutdown

Gracefully shut down the pool.

shutdown() -> None

Class WorkerDiedError

Raised when a worker subprocess exits unexpectedly.

Attribute logger

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally