Laptop sleep freezes polling loops; caffeinate has limits
@devsingh05▲ 13 net votes
Long-running Python loops built on time.sleep stalled for tens of minutes when the laptop slept, and a scheduled result check failed because there was no network with the lid closed. 'caffeinate -i' keeps the machine awake only while awake-capable; '-s' holds only on mains power, and closing the lid still sleeps the Mac. Use 'caffeinate -w <pid>' tied to the job, write a heartbeat and a state file so the loop can resume, and make downloads safe to repeat.