Comments (6)
Np :)
If I ever test on linux I'll be sure to update here as well.
from wakepy.
Hi @JonLevin25, glad that you like it!
On the linux & mac versions, I have say honestly that I don't know, and would refer to the documentation of the underlying apps that keep the process awake (_linux.py
and _darwin.py
).
On Windows, I would actually very much guess that the behaviour is the opposite of what you've suggested. As you have read, in _win.py
the SetThreadExecutionState is called, which in my understanding kind of sets a flag for the operating system to not start sleeping:
ES_CONTINUOUS
0x80000000
Informs the system that the state being set should remain in effect until the next call that uses ES_CONTINUOUS and one of the other state flags is cleared.
This also means that in practice one could, with current implementation, accidentally remove this flag with some other process/thread (even outside of python).
I fully agree that some sort of table in the docs would be handy! :)
from wakepy.
About windows - I thought the same thing at first.
But the name suggests SetThreadExecutionState
is local to the current Thread. (which should die with the process)
I've tested this and it is indeed reset:
import wakepy
wakepy.set_keepawake()
while True:
pass
(In admin terminal)
PS C:\Users\Jon> powercfg -requests
DISPLAY:
None.
SYSTEM:
[PROCESS] ...\AppData\Local\Programs\Python\Python310\python.exe
AWAYMODE:
None.
EXECUTION:
None.
PERFBOOST:
None.
ACTIVELOCKSCREEN:
None.
After killing the process (from PyCharm or Task Manager)
PS C:\Users\Jon> powercfg -requests
DISPLAY:
None.
SYSTEM:
None.
AWAYMODE:
None.
EXECUTION:
None.
PERFBOOST:
None.
ACTIVELOCKSCREEN:
None.
from wakepy.
Hi @JonLevin25,
Oh wow, thanks for the info! You're right! Nice catch 😎
The execution state flag is really tied to the process. I tested by using threading.Thread
s, and whenever a thread is done executing and dies, the flag disappears from powercfg -requests
listing. Also, it is possible to have multiple threads (& processes) having flags of their own; all of the processes must either remove their flags or die before windows would go into sleep. See, for example here, there are two processes calling wakepy.set_keepawake
, with the second one also having 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.
from wakepy.
Nice! I also added a Summary table to the README.md.
from wakepy.
This is now documented for Windows and Linux. Created new ticket (#25) for macOS so this one can be closed. Thanks @JonLevin25 for your contribution !
from wakepy.
Related Issues (20)
- inv test failing on Windows
- Code coverage not shown on windows (inv test)
- Importing wakeypy nukes logging config HOT 3
- GitHub Releases are not shown (except to repo owner) HOT 3
- There's still one place calling the log methods of the logging module directly (logging.info())
- Publish also to conda-forge?
- Rename the CLI flags: Have same naming convention everywhere. --keep-presenting and -r
- Android support
- Add support for BSD systems HOT 3
- Keep a remote server awake after closing SSH connection? HOT 2
- Improve Supported Platforms table
- Wakepy on browser (Pyodide, PyPy.js, Brython, Transcrypt, Skulpt)
- Add support for cygwin
- Add support for ChromeOS
- Add to docs: "Prior to Windows 11 power requests were held an additional 2 minutes after they were dropped by the application. "
- Update migration guide: Add on_fail action example
- Docs: Tell that (most of?) the wakepy Methods will keep the idle/sleep timer at zero for the duration of the context manager
- Conditionally using wakepy modes
- on_success / on_activation hook? (similar to on_fail)
- Include `on_fail="warn"` in the examples of the README / docs?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wakepy.