wakepy
wakelock / keep-awake / stay-awake
What it is and what it does
Wakepy is a cross-platform Python library and CLI tool that prevents your system from automatically sleeping, suspending, or locking the screen during long-running tasks. It works on Windows (via SetThreadExecutionState), macOS (via caffeinate), and Linux/Unix systems with GNOME, KDE Plasma, or Freedesktop.org desktop environments. The package offers two main modes: keep.running inhibits sleep and suspend but allows screen lock and screensaver, while keep.presenting also keeps the display active and prevents screen lock.
You use it either as a decorator or context manager around your code, or invoke it from the command line. It's designed to be non-disruptive—it uses only the system APIs provided for this purpose, never simulates keyboard or mouse input—and safe to crash; killing the process leaves no lingering state. The package has minimal dependencies: on Linux it requires jeepney for D-Bus communication, and on Python 3.9 and earlier it needs typing-extensions; otherwise it has no Python dependencies.
Use it for:
- Training machine learning models or running long data-processing pipelines that must not be interrupted by system sleep
- Video encoding, transcoding, or upscaling tasks that require the system to stay awake for hours
- Displaying dashboards, monitoring applications, or videos that require the screen to remain on and unlocked
- Web scraping or data archival operations that run unattended overnight or over many hours
- Automated hardware control or instrumentation tasks (e.g., knitting machines, scientific instruments) that must complete without interruption
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wakepy prevents a system from sleeping or locking the screen during long-running tasks, with separate modes for keeping the CPU awake or keeping the display active.
Yes. Wakepy is actively maintained, has zero known vulnerabilities, minimal dependencies, and a permissive MIT license. It solves a real cross-platform problem using proper system APIs rather than hacks. Install it if you need to prevent sleep or lock during long tasks.
Install
wakepy on PyPI
pip
pip install wakepyuv
uv add wakepypoetry
poetry add wakepyInstalling wakepy
Before you install
Low friction: pure Python wheel with only two runtime dependencies (jeepney and typing-extensions), both lightweight. Active maintenance with recent releases; last commit 2026-04-01.
License in practice
MIT License (permissive) — you can use, modify, and distribute wakepy freely in commercial and private projects with minimal restrictions.
Quickstart
pip install wakepy
from wakepy import keep
@keep.running
def long_task():
# Your long-running code here
pass
Verify before relying
- Whether the package works reliably across all listed Unix desktop environments without additional system configuration
- Performance overhead when running keep.running or keep.presenting modes over extended periods
Package facts
| License | MIT License Copyright (c) 2021-2024 Niko Föhr Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — jeepney, typing-extensions |
| Maintenance | actively maintained — 188 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 168,094/month — #10,454 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: wakepy-1.0.0-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
filelockProvides a platform-independent file locking…
permissive · top 100 on PyPI
celery_oncePrevents duplicate execution and queuing of…
permissive · top 15,000 on PyPI
pyps4-2ndscreenUnofficial Python library to control…
copyleft · top 15,000 on PyPI
mssCaptures screenshots from one or all monitors…
permissive · top 5,000 on PyPI
appnopeDisables App Nap on macOS >= 10.9 to prevent…
permissive · top 5,000 on PyPI
screeninfoDetects and reports the location, dimensions,…
permissive · top 5,000 on PyPI
fastenersProvides cross-platform locks for synchronizing…
permissive · top 5,000 on PyPI
dearpyguidearpygui is a GPU-accelerated GUI framework…
permissive · top 15,000 on PyPI
win-precise-timeProvides high-resolution time measurement and…
permissive · top 15,000 on PyPI
pyobjc-framework-ScreenSaverProvides Python bindings to macOS's ScreenSaver…
permissive · top 15,000 on PyPI