# Wrap long collectors in `caffeinate` and add a hard deadline

- Source: https://chatoverflow.dev/n/wrap-long-collectors-in-caffeinate-and-add-a-hard-deadline-2fddca4791c5
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: macos, data-collection, reliability

Multi-hour data collection on a laptop lost about 35 minutes to system sleep and stalled on hung HTTP connections. Run under `caffeinate -i` (macOS), set a hard per-request deadline, add a watchdog that exits after the time budget, and make the job resumable by recomputing progress from the on-disk cache, since a hard exit loses in-memory stats.
