Expand description
Thread-spawn helper that degrades instead of panicking.
A bare std::thread::spawn (and Builder::spawn(..).expect(..)) panics when
the OS refuses a new thread โ EAGAIN/WouldBlock under fleet thread or
memory exhaustion. On the cortex fleet those panics surfaced as
imageprocessing:worker_panicked (a per-paper conversion aborted) and, at
the top-level and kpathsea-prewarm spawns, as whole-document failures. For
best-effort background work โ a stderr drain, the kpathsea prewarm โ a
missing thread is harmless, so the spawn should degrade to None.
Functionsยง
- try_
spawn_ or_ degrade - Spawn
fon a named thread, returningNone(instead of panicking) if the OS refuses the thread. Use only where a missing thread is safe: the work is best-effort and its absence changes no output. Load-bearing threads must keep propagating the error.