GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-59705: Export threading.Thread() names to the OS by ZackerySpytz · Pull Request #14578 · python/cpython

Conversation

@ZackerySpytz

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

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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

https://bugs.python.org/issue15500

  • Issue: Python should support exporting thread names to the OS #59705

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jaketesler, Fryuni, debauer, and arhadthedev reacted with thumbs up emoji
All reactions
  • 👍 4 reactions
@ZackerySpytz
bpo-15500: Export threading.Thread() names to the OS
fbbd740
Call pthread_setname_np() et al. with the name argument passed to
threading.Thread().
@the-knights-who-say-ni the-knights-who-say-ni added the CLA signed label Jul 3, 2019
@bedevere-bot bedevere-bot added the awaiting review label Jul 3, 2019
@ZackerySpytz

ZackerySpytz commented Jul 3, 2019

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@debauer

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

pitrou
pitrou reviewed Jan 18, 2022
View reviewed changes
Comment thread Lib/threading.py
if _HAVE_THREAD_NATIVE_ID:
self._set_native_id()
if _HAVE_SET_THREAD_NAME:
_set_thread_name(self.name)

@pitrou pitrou Jan 18, 2022

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@encukou encukou Mar 18, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@MaxwellDupre

MaxwellDupre commented May 10, 2022

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.

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bra bra mannequin mentioned this pull request Apr 10, 2022
Python should support exporting thread names to the OS #59705
Closed
@ezio-melotti ezio-melotti removed the CLA signed label Jul 13, 2022
@erlend-aasland 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
encukou reviewed Mar 18, 2024
View reviewed changes

@encukou encukou left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
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);

@encukou encukou Mar 18, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

@encukou encukou Mar 18, 2024

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@vstinner vstinner mentioned this pull request Nov 27, 2024
gh-59705: Add _thread.set_name() function #127338
Merged
@vstinner

vstinner commented Nov 27, 2024

Copy link
Copy Markdown
Member

New attempt to implement this feature: #127338

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner

vstinner commented Dec 6, 2024

Copy link
Copy Markdown
Member

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vstinner vstinner closed this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou left review comments
@pitrou pitrou pitrou left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

awaiting review

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@ZackerySpytz @debauer @MaxwellDupre @vstinner @encukou @pitrou @the-knights-who-say-ni @ezio-melotti @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.