skillfed

wakepy

wakelock / keep-awake / stay-awake

wakepy v1.0.0 168.1K downloads/30d#10,454 on PyPI261
Permissive 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) Active released

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 wakepy

uv

uv add wakepy

poetry

poetry add wakepy

Installing 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

Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIXOperating System :: POSIX :: BSDOperating System :: POSIX :: BSD :: FreeBSDOperating System :: POSIX :: BSD :: NetBSDOperating System :: POSIX :: BSD :: OpenBSDOperating System :: POSIX :: LinuxOperating System :: POSIX :: OtherOperating System :: UnixProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Free ThreadingProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: UtilitiesTyping :: Typed

Tags

prevent system sleepkeep screen awakewakelock pythoninhibit suspendstay-awake cross-platformsystem sleep preventionkeep cpu running
system-controlcross-platformtask-automation

More Utilities packages