Appnope

0.1.4 · maintenance · verified Thu Apr 09

Appnope is a small Python library for macOS (10.9 and later) that disables App Nap for the current process. It is primarily used in long-running Python applications and interactive environments like Jupyter notebooks to prevent them from being suspended when in the background. The current version is 0.1.4, and the library is in maintenance, receiving updates mainly for compatibility.

Warnings

Install

Imports

Quickstart

The simplest way to use appnope is to import it. This will automatically disable App Nap for the current Python process on supported macOS versions. For more granular control, `set_appnap_enabled()` can be used.

import appnope
import time

print("App Nap is now disabled for this process (macOS 10.9+).")
print("Sleeping for 10 seconds. Check activity monitor if App Nap usually affects this process.")

time.sleep(10)

# To explicitly re-enable or disable App Nap later:
# appnope.set_appnap_enabled(True) # Re-enable App Nap
# appnope.set_appnap_enabled(False) # Disable App Nap again

print("Done. App Nap status remains as last set.")

view raw JSON →