Keep Julia Awake: NoSleep.jl

When you run long Julia simulations or heavy computations on a laptop, you don’t want your machine to fall asleep in the middle of the job.
On Windows, macOS, or Linux, the system may suspend itself even if Julia is still crunching numbers — leading to…


This content originally appeared on DEV Community and was authored by Evgeny Metelkin

When you run long Julia simulations or heavy computations on a laptop, you don't want your machine to fall asleep in the middle of the job.

On Windows, macOS, or Linux, the system may suspend itself even if Julia is still crunching numbers — leading to wasted time, broken HTTP calls, or stalled jobs.

This is the reason NoSleep.jl exists: a lightweight cross-platform Julia package that prevents your machine from falling asleep during long computations.

How it works

  • Windows: uses WinAPI SetThreadExecutionState.
  • macOS: uses the built-in caffeinate tool.
  • Linux (systemd): uses systemd-inhibit.

Each backend is safe: once your block finishes (or Julia exits), the inhibitor is released automatically.

Usage

Block form

using NoSleep

with_nosleep() do
    # Your long computation
end

Keep the display awake too

with_nosleep(; keep_display=true) do
    # Your long computation
end

Notes & Side-effects

  • Saves you from wasted hours if the OS suspends mid-job. No frustration.

  • Useful when running code overnight or unattended.

  • Cross-platform: works out of the box on Windows, macOS, and Linux.

  • Does not prevent suspend/hibernate when you close the lid or press the laptop's power button — it only blocks automatic idle sleep.

  • Feedback and contributions welcome: GitHub repo.


This content originally appeared on DEV Community and was authored by Evgeny Metelkin


Print Share Comment Cite Upload Translate Updates
APA

Evgeny Metelkin | Sciencx (2025-10-04T07:00:00+00:00) Keep Julia Awake: NoSleep.jl. Retrieved from https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/

MLA
" » Keep Julia Awake: NoSleep.jl." Evgeny Metelkin | Sciencx - Saturday October 4, 2025, https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/
HARVARD
Evgeny Metelkin | Sciencx Saturday October 4, 2025 » Keep Julia Awake: NoSleep.jl., viewed ,<https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/>
VANCOUVER
Evgeny Metelkin | Sciencx - » Keep Julia Awake: NoSleep.jl. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/
CHICAGO
" » Keep Julia Awake: NoSleep.jl." Evgeny Metelkin | Sciencx - Accessed . https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/
IEEE
" » Keep Julia Awake: NoSleep.jl." Evgeny Metelkin | Sciencx [Online]. Available: https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/. [Accessed: ]
rf:citation
» Keep Julia Awake: NoSleep.jl | Evgeny Metelkin | Sciencx | https://www.scien.cx/2025/10/04/keep-julia-awake-nosleep-jl/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.