nbconvert "Cell execution timed out" TimeoutError in CI
nbclient enforces a per-cell timeout (default 30 seconds for some configs). If a cell does not finish in time, nbclient interrupts the kernel and raises a TimeoutError naming the cell that ran too long. Slower CI hardware makes this more likely than on a developer laptop.
What this error means
jupyter nbconvert --execute fails with "nbclient.exceptions.CellTimeoutError" or "TimeoutError: Cell execution timed out" pointing at a long-running cell.
nbclient.exceptions.CellTimeoutError: A cell timed out while it was being executed,
after 30 seconds.
The message was: Cell execution timed out.
Here is a preview of the cell contents:
-------------------
model.fit(X, y, epochs=50)Common causes
A genuinely slow cell exceeds the timeout
Training, large downloads, or heavy computation take longer than the configured per-cell limit, especially on shared CI runners.
A cell blocks waiting on input or a hung resource
A cell that waits on stdin, a network call, or a lock never returns, so the timeout fires.
How to fix it
Raise the per-cell timeout
Give slow cells more time, or disable the limit with -1 when the workload is legitimately long.
jupyter nbconvert --to notebook --execute \
--ExecutePreprocessor.timeout=600 notebook.ipynbMake heavy cells faster or skip them in CI
- Reduce iterations or data size for the CI run.
- Remove blocking input/network calls from executed cells.
- Tag long cells to skip when running in CI if they are not under test.
How to prevent it
- Set
--ExecutePreprocessor.timeoutto a value that fits slower CI hardware. - Avoid cells that block on stdin or external resources during execution.
- Keep CI notebook runs small (fewer epochs, smaller datasets).