Comments (8)
I'll work on a patch to suppress the GIL warnings and behavior in the free-threaded build, as well as a few small thread-safety issues on some OS's if certain psutil functions are used from multiple threads concurrently.
from psutil.
I don't know enough about free-thread cPython to give any guidance. Some work in this sense was done in #2401. @colesbury any idea?
from psutil.
happens on windows as well.
from psutil.
Can you guys run:
python3 -c "import faulthandler; faulthandler.enable(); import psutil"
...and paste the output?
from psutil.
Administrator in ~\Documents\tests via 🐍 v3.13.0b1 (313t-venv)
❯ python -c "import faulthandler; faulthandler.enable(); import psutil"
Windows fatal exception: access violation
Current thread 0x00002388 (most recent call first):
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1315 in create_module
File "<frozen importlib._bootstrap>", line 813 in module_from_spec
File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "C:\Users\NuitkaDevOps\Documents\cmbos\313t-venv\Lib\site-packages\psutil\_pswindows.py", line 35 in <module>
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1021 in exec_module
File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
File "C:\Users\NuitkaDevOps\Documents\cmbos\313t-venv\Lib\site-packages\psutil\__init__.py", line 110 in <module>
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1021 in exec_module
File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "<string>", line 1 in <module>
from psutil.
I get this, on Mac OS:
pkoning:foo pkoning$ PYTHONFAULTHANDLER=1 python3.13t -c "import psutil"
Fatal Python error: Segmentation fault
Current thread 0x0000000104750580 (most recent call first):
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1316 in create_module
File "<frozen importlib._bootstrap>", line 813 in module_from_spec
File "<frozen importlib._bootstrap>", line 921 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
File "/Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/site-packages/psutil/_psposix.py", line 28 in <module>
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1022 in exec_module
File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
File "/Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/site-packages/psutil/_psosx.py", line 13 in <module>
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1022 in exec_module
File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1415 in _handle_fromlist
File "/Library/Frameworks/PythonT.framework/Versions/3.13/lib/python3.13/site-packages/psutil/__init__.py", line 124 in <module>
File "<frozen importlib._bootstrap>", line 488 in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 1022 in exec_module
File "<frozen importlib._bootstrap>", line 935 in _load_unlocked
File "<frozen importlib._bootstrap>", line 1331 in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1360 in _find_and_load
File "<string>", line 1 in <module>
Segmentation fault: 11
This is with the published release (from pip install). Should we try it with the current latest code from github?
from psutil.
Sorry for the ping ponging of issues between projects. I think this is mostly not specific to psutil, but I'm not entirely sure yet.
I'd like to focus on macOS first, because I think it'll be easier to get it into a good state.
@pkoning2, how did you get Python, pip, and psutil installed?
Here are some issues I noticed on macOS:
- macOS installer appears to be missing pip for 3.13t.
- python3.13t -m ensurepip installs 24.0, which is not compatible. You need 24.1. Unfortunately, I think this issue will persist in beta 3 and won't be fixed until beta 4.
Here's what I did to successfully install psutil:
- Install Python 3.13 with free-threading binaries
python3.13t -m ensurepip && python3.13t -m pip install --upgrade pip
python3.13t -m pip install psutil
There's still the issue that importing psutil enables the GIL:
<frozen importlib._bootstrap>:488: RuntimeWarning: The global interpreter lock (GIL) has been enabled to load module 'psutil._psutil_osx', which has not declared that it can run safely without the GIL. To override this behavior and keep the GIL disabled (at your own risk), run with PYTHON_GIL=0 or -Xgil=0.
That can be fixed in this project, but the other issues are more CPython related.
from psutil.
Yes, what I did roughly follows the steps you describe. I didn't realize that pip was out of date and this is the first time I've run into a situation where it actually matters.
So yes, now you have the GIL lock complaint. I ran python3.13t with that flag to suppress the warning, and psutil seems to work fine. At least for net_if_addrs()
which is the only function I have used so far. So perhaps all that is needed is to supply the flag that says to Python that you're compatible with the free-threading flavor?
I noticed the help mentions net_connections()
; that fails on 3.13 (either flavor) with an "operation not permitted" exception, but it seems to work on 3.12.
from psutil.
Related Issues (20)
- [Linux] Get laptop charging speed (in Watts)
- process_iter(): no longer check whether PIDs have been reused HOT 1
- [Linux / FreeBSD] evaluate using `pidfd_send_signal()` for signaling processes HOT 5
- Don't build with limited API for 3.13 free-threaded build
- [macOS] active system memory is inaccurate HOT 1
- Rename Process.connections() to Process.net_connections()
- Remove deprecated `Process.memory_info_ex()`
- [macOS] psutil.Process(pid).cpu_percent calculation result is inaccurate HOT 6
- [macOS] Lacking defines in <sys/mount.h> breaks build on legacy OS X HOT 1
- [Windows] Python 3.10 wheels are missing on PYPI for psutil 5.9.8
- blkio_ticks is not supported in solaris based system. (ret['blkio_ticks'] = fields[39] # aka 'delayacct_blkio_ticks')
- [Debian 12 bookworm] Repeating spikes in temperatures samples HOT 3
- About Error `FileNotFoundError: [Errno 2] No such file or directory: '/proc/12825/stat'` the some suggest HOT 1
- [Linux] cannot import name '_psutil_linux' from partially initialized module 'psutil' (most likely due to a circular import) HOT 3
- [mac os] thread id is not the native_id
- [All] Request: Make new Release and update PyPi
- [Windows] win_service_get by PID and not by name HOT 3
- [macOS] build failure on OS X 10.4 HOT 1
- 'psutil' has no attribute 'sensors_temperatures'
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 psutil.