This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 1.2.0 instead.
Reason given by maintainers: Concurrent safe problem
Keep Awake
Keep your system on and screen on, it will not fall asleep. It is useful in some long term calculations.
How to use?
pip install keep_awake==1.1.0
This module exposes only two methods: prevent_sleep and allow_sleep, both of them taks no arguments.
prevent_sleep returns a boolean value that indicates whether the operation is successful. After you call this method, your system and screen will keep working until you invoke allow_sleep.
You won't have any exceptions by calling any methods twice, or calling allow_sleep without calling prevent_sleep, they have built-in protection.
If you forget to call allow_sleep before exiting your program, it doesn't matter, it will back to usual once the module is released.
We also provide a context manager for you to manage the state automatically, just like this:
from keep_awake import KeepAwakeGuard
with KeepAwakeGuard():
# do your work here
Supported platforms
macOS✅
Both arm64 and x64 are OK, this code only depends on IOKit and CoreFoundation, which is built-in macOS Framework.
Methods on macOS are concurrent safe.
Windows✅
We didn't test widely on various versions of Windows because I have no Windows computer :(
But basically, it can work fine on Windows 10 x64 and Windows 11 x64. I have already tested.
Keeping system awake on Windows needs a dedicated thread to sync periodically(typically 1 second), so it is hard to perform concurrent-control. Do NOT try to call methods in less than 1 second!
Linux⚠️
Linux distros are various, we can only support Gnome and KDE. They have dbus api so this part is implemented in pure python. If you need this feature, please install with this command:
pip install keep_awake[linux]
If you failed to install, try to use your package manager to install cmake, pkg-config, libdbus-1-dev and libglib2.0-dev.
Methods on Linux are concurrent safe.
Building & Debugging
We use uv to manage the project, so it is very easy to build and test it.
For building:
uv build
For testing
uv run pytest
Release files for keep-awake 1.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 | |
|---|---|---|---|
| keep_awake-1.1.0.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| keep_awake-1.1.0-cp314-cp314-macosx_26_0_arm64.whl | CPython 3.14 | CPython 3.14 | macOS 26.0+ ARM64 | Details |
Total release size: 15.8 kB
Release files / keep_awake-1.1.0.tar.gz
| Download URL | keep_awake-1.1.0.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
61ba787431472b82d4e952061241135099389247fd7531ec445d0e86333c53e8
|
|
BLAKE2b-256 checksum How to use checksums |
c829f8fe1ea095b72134f85054fb76049ef1db432e19c593090df31562f7c5ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.4
|
Release files / keep_awake-1.1.0-cp314-cp314-macosx_26_0_arm64.whl
| Download URL | keep_awake-1.1.0-cp314-cp314-macosx_26_0_arm64.whl |
|---|---|
| Size | 8.1 kB |
| Tags | CPython 3.14 macOS 26.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f044be917bdfb206a01b38d91a7111197f8c272413d564d36f33d51764e1cc87
|
|
BLAKE2b-256 checksum How to use checksums |
6425b5fee469d36102776d2bf52e56e8281405fcf2a009940cfa4d13427c8d64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.4
|