FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-59705: Export threading.Thread() names to the OS by ZackerySpytz · Pull Request #14578 · python/cpython · GitHub

/ cpython Public

gh-59705: Export threading.Thread() names to the OS - #14578

Closed
ZackerySpytz wants to merge 1 commit into
python:mainfrom
ZackerySpytz:bpo-15500-export-thread-names
Closed

gh-59705: Export threading.Thread() names to the OS#14578
ZackerySpytz wants to merge 1 commit into
python:mainfrom
ZackerySpytz:bpo-15500-export-thread-names

Conversation

ZackerySpytz commented Jul 3, 2019
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

Call pthread_setname_np() et al. with the name argument passed to
threading.Thread().

https://bugs.python.org/issue15500

Call pthread_setname_np() et al. with the name argument passed to
threading.Thread().

Copy link
Copy Markdown
Contributor Author

Unfortunately, the string passed to pthread_setname_np() must be less than 16 chars on Linux, so the name may be truncated.

debauer commented Jan 18, 2022

Copy link
Copy Markdown

Will this ever happen?! The Issue has this year the 10th anniversary. In the Issue @eryksun also provides Code for Windows... so let this happen.

Comment thread Lib/threading.py
if _HAVE_THREAD_NATIVE_ID:
self._set_native_id()
if _HAVE_SET_THREAD_NAME:
_set_thread_name(self.name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This should probably be more sophisticated, e.g. f"{sys.executable} [thread {self.name!r}]"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That wouldn't work well for platforms with the 16-character limitation.

Copy link
Copy Markdown
Contributor

I would expect to see some changes to the Docs, how use, and if any affect on whats out there running now. Probably need to add version changed.

erlend-aasland changed the title bpo-15500: Export threading.Thread() names to the OS gh-59705: Export threading.Thread() names to the OS Jan 5, 2024

encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This needs tests, which in turn will need a getter function -- at least a private one.

Comment thread Python/thread_pthread.h
int ret = 0;
#ifdef __APPLE__
// On macOS, pthread_setname_np() can only set the calling thread's name.
ret = pthread_setname_np(buf);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It seems (from the man page) that macOS doesn't have the 16-character limitation. Could we pass the original buffer here?

Comment thread Lib/threading.py
if _HAVE_THREAD_NATIVE_ID:
self._set_native_id()
if _HAVE_SET_THREAD_NAME:
_set_thread_name(self.name)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

That wouldn't work well for platforms with the 16-character limitation.

Copy link
Copy Markdown
Member

New attempt to implement this feature: #127338

vstinner commented Dec 6, 2024

Copy link
Copy Markdown
Member

#127338 was merged instead. Thanks for your contribution anyway!

vstinner closed this Dec 6, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL