Skip to main content

A tool to keep Mac OS X from sleeping

Project description

Use this module to prevent your Mac OS X system from sleeping while executing a long-running python script.

Quick Start

Just import caffeine. That’s it! You Mac OS X system will not sleep as long as the interpreter remains alive. No need to run any other commands. But if you want slightly finer controls, a few functions are available.


Use the on function to create a power assertion. Set display=True to also keep your display from sleeping. The default of display=False will allow your display to sleep but will keep your system awake so processing can continue. If a power assertion is active, calling on() with display set to the other value will change the assertion. Calling on() with the same value is a harmless no-op.

Use the off function to release any power assertion before your interpreter exits.


Calls pmset -g assertions to verify what power assertions are active.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
caffeine-0.5.tar.gz (2.4 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page