Git Product home page Git Product logo

Comments (8)

colesbury avatar colesbury commented on June 27, 2024 1

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.

giampaolo avatar giampaolo commented on June 27, 2024

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.

KRRT7 avatar KRRT7 commented on June 27, 2024

happens on windows as well.

from psutil.

giampaolo avatar giampaolo commented on June 27, 2024

Can you guys run:

python3 -c "import faulthandler; faulthandler.enable(); import psutil"

...and paste the output?

from psutil.

KRRT7 avatar KRRT7 commented on June 27, 2024
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.

pkoning2 avatar pkoning2 commented on June 27, 2024

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.

colesbury avatar colesbury commented on June 27, 2024

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.

pkoning2 avatar pkoning2 commented on June 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.