wakepy
wakepy copied to clipboard
Support multiprocessing
It might be interesting to have multiprocessing-supporting approach that uses a counter under the hood; for each set_keepawake()
call there should be unset_keepawake()
and for example if one calls set_keepawake()
three times, the unset_keepawake()
should be called three times before it would actually bet unset. In current implementation, if there were three long running processes (2hrs, 30hrs and 30hrs), and all of them would be using unset_keepawake()
, PC would sleep soon after 2hrs.
Another possible implementation would be to use mouse movement or pressing a key, but these typically need some (or a lot) of other dependencies.
Update: Multiprocessing is actually supported out of the box at least in Windows. Each call of wakepy.set_keepawake
will create a new flag in Windows. This can be checked in admin Powershell with the powercfg -requests
command. For example, here there are two processes that have called wakepy.set_keepawake
(second one with keep_screen_awake=True
:
PS C:\WINDOWS\system32> powercfg -requests
DISPLAY:
[PROCESS] \Device\HarddiskVolume3\Python\Python385-64\python.exe
SYSTEM:
[PROCESS] \Device\HarddiskVolume3\Python\Python385-64\python.exe
[PROCESS] \Device\HarddiskVolume3\Python\Python385-64\python.exe
AWAYMODE:
None.
EXECUTION:
None.
PERFBOOST:
None.
ACTIVELOCKSCREEN:
None.
The behavior in other platforms (Linux, Mac) is still unknown. See also: https://github.com/np-8/wakepy/issues/16
Multiprocessing is now supported on Windows and Linux. On mac, should test if multiprocessing is possible or not.