wakepy
wakepy copied to clipboard
Bug: Windows/SetThreadExecutionState based modes on same thread are not isolated from each other
As mentioned on https://github.com/fohrloop/wakepy/issues/60, there is a bug in the old implementation (wakepy/_deprecated/_windows.py). Since the SetThreadExecutionState changes "execution state" of current thread to either
- Prevent display power management
- Prevent suspend
- No prevented
if someone uses multiple wakelocks / activates multiple modes in a single thread, it will not work. For example this:
def foo():
baz()
with keep.running():
quux()
with keep.presenting():
foo()
bar()
- Start with entering
keep.presenting
mode. -
keep.presenting
mode is active duringbaz()
- This is overridden completely when entering
keep.running
mode, which is active duringquux()
. Only sleep is prevented, but display might turn off. - When the
keep.running
mode exits, the whole execution state is cleared with ES_CONTINUOUS - The
bar()
is being run without any mode active at all. System could go to sleep and display might turn off.
This bug has been there since the first version of wakepy.
Task
- Make it possible to use two modes in same thread at same time.