python -m pip install wakepy
from wakepy import keep
# Prevent sleep
Prevent screensaver/screen lock (and sleep):
with keep.running():
# do stuff that takes long time
# Prevent screensaver/screen lock (and sleep):
from wakepy import keep
with keep.presenting():
# do stuff that takes long time