Skip to content

add Python 3.14 compatible logic to check if a thread is alive #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lancelote
Copy link

Hi Fabio, hope you are doing great.

Python 3.14.0b1 is available, and I'm experimenting with adopting it for my projects. Unfortunately, the debugger is not yet compatible with it. I'm currently looking into fixing it in PyCharm, and decided to first open a PR upstream. Would you consider contributions for Python 3.14 support, or is it too early?

Speaking of the changes ...

  • _handle was renamed to _os_thread_handle in [3.13] gh-132578: Rename the threading.Thread._handle field (GH-132696) python/cpython#132789
  • I see you have a separate module for checking if the thread is alive - _pydev_bundle/pydev_is_thread_alive.py. Given that - was there a special reason why you didn't use it in _pydevd_sys_monitoring/_pydevd_sys_monitoring.py?
  • I re-generated _pydevd_sys_monitoring/_pydevd_sys_monitoring_cython.pyx with build_tools/generate_code.py
  • In _pydev_bundle/pydev_is_thread_alive.py you write "Hack for https://www.brainwy.com/tracker/PyDev/363", I wonder if this is still relevant in the Python >=3.8 world, perhaps the whole module could be drastically simplified

Thank you for your time.

return not self.thread._is_stopped
else:
return not self.thread._handle.is_done()
return is_thread_alive(self.thread)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally any checks for Python 3.12 onwards would be done here and not delegated to a pure-python implementation (i.e.: the constructor should determine which check to do and here it uses the proper approach without calling out to non-cython code).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger that, fixed

- don't import extra pure-Python code
- cache `hasattr` calls
@lancelote lancelote requested a review from fabioz May 22, 2025 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants