⚡ nosleep-py
A zero-overhead, native Windows sleep and screen-lock prevention library and CLI tool.
No fake mouse movement. No CPU usage. Zero dependencies. Directly leverages Windows Kernel execution state flags (SetThreadExecutionState).
📦 Installation
pip install nosleep-py
Or with uv:
uv add nosleep-py
🚀 Python Library Usage
1. Context Manager (Recommended)
Automatically protects a block of code from system sleep, and safely restores normal behavior when finished (even if an exception occurs):
import time
from nosleep_py import keep_awake
# Keep system and screen awake during training/rendering
with keep_awake():
print("Doing 2-hour heavy processing...")
time.sleep(7200)
# Back to normal automatically!
2. Manual Controls
import nosleep_py
# Turn ON sleep prevention
nosleep_py.prevent_sleep(keep_display=True)
# ... Do your long-running tasks ...
# Turn OFF sleep prevention
nosleep_py.allow_sleep()
3. CPU Awake Only (Allow Screen/Display to Turn Off)
with keep_awake(keep_display=False):
# Perfect for background downloads or overnight batch processing
download_large_dataset()
💻 CLI Terminal Usage
Once installed, you can run nosleep directly from any terminal:
# Keep awake indefinitely (Press Ctrl+C to stop)
nosleep
# Keep awake for 30 minutes, then auto-stop
nosleep --minutes 30
# Keep CPU awake only (allow monitor to turn off)
nosleep --minutes 60 --no-display
🛡️ License
MIT License. Free for personal and commercial use.
Metadata
Release files for nosleep-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nosleep_py-0.1.0.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nosleep_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / nosleep_py-0.1.0.tar.gz
| Download URL | nosleep_py-0.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
301c5c97ced31aa04c972da617ba9939d58d0540a28fe25035e24b23628893ac
|
|
BLAKE2b-256 checksum How to use checksums |
707d49e0e72a2c31672d4d665010dbc074c6b61c0d7bee7a3d5328cf4a210347
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nosleep_py-0.1.0-py3-none-any.whl
| Download URL | nosleep_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b22f99a15e1a5eab4809c520610fa3ee81ab23f4f759d7e8cf97b05d14676633
|
|
BLAKE2b-256 checksum How to use checksums |
bc509401f05eae134acb2c633b987bd0acedd9ba71045bf3fb8ff4835e8fc389
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|