[issue15500] Python should support naming threads

2015-11-29 Thread Марк Коренберг

Changes by Марк Коренберг :


--
nosy: +mmarkk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2014-11-06 Thread Kovid Goyal

Kovid Goyal added the comment:

Just FYI, a pure python2 implementation that monkey patches Thread.start() to 
set the OS level thread name intelligently.

import ctypes, ctypes.util, threading
libpthread_path = ctypes.util.find_library(pthread)
if libpthread_path:
libpthread = ctypes.CDLL(libpthread_path)
if hasattr(libpthread, pthread_setname_np):
pthread_setname_np = libpthread.pthread_setname_np
pthread_setname_np.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
pthread_setname_np.restype = ctypes.c_int
orig_start = threading.Thread.start
def new_start(self):
orig_start(self)
try:
name = self.name
if not name or name.startswith('Thread-'):
name = self.__class__.__name__
if name == 'Thread':
name = self.name
if name:
if isinstance(name, unicode):
name = name.encode('ascii', 'replace')
ident = getattr(self, ident, None)
if ident is not None:
pthread_setname_np(ident, name[:15])
except Exception:
pass  # Don't care about failure to set name
threading.Thread.start = new_start

--
nosy: +kovid

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-07 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-06 Thread Attila Nagy

Attila Nagy added the comment:

I don't think this should be done by default as it will break people's 
expectations and, perhaps worse, compatibility.
I won't mind another thread naming API, if somebody does this. :)
But personally I expected python to name my threads (and if the OS supports it, 
on that level), I was actually surprised to see that it doesn't, mostly because 
I remembered a patch for FreeBSD, which did this years ago, so I thought it has 
been merged into mainline since then.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-06 Thread R. David Murray

R. David Murray added the comment:

It is indeed the compatibility that is the worse issue.  The problem is what 
people have gotten used to and may have coded their applications to expect/deal 
with. what people have gotten used to.  I agree with you that most people would 
*not* find it surprising to see the name reflect in the OS, but I don't think 
the convenience of that is worth introducing a potential backward 
incompatibility.

On the other hand, I think this might be an appropriate place to use a global 
control, so that getting thread names out to the OS would require adding just a 
single line of code to any given application.  I know of an application that 
does this.  It chose to implement it as a global change, and that makes sense 
to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-06 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
Removed message: http://bugs.python.org/msg167559

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-06 Thread R. David Murray

R. David Murray added the comment:

It is indeed the compatibility that is the worse issue.  The problem is what 
people have gotten used to and may have coded their applications to expect/deal 
with.  I agree with you that most people would *not* find it surprising to see 
the name reflected in the OS, but I don't think the convenience of that is 
worth introducing a potential backward incompatibility.

On the other hand, I think this might be an appropriate place to use a global 
control, so that getting thread names out to the OS would require adding just a 
single line of code to any given application.  I know of an application that 
does this.  It chose to implement it as a global change, and that makes sense 
to me.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-04 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-04 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
nosy: +flox

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-04 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't think this should be done by default as it will break people's 
expectations and, perhaps worse, compatibility.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-08-01 Thread Christian Heimes

Christian Heimes added the comment:

+1

win32 supports thread names, too. 
http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx

--
nosy: +christian.heimes

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-07-31 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-07-30 Thread Attila Nagy

New submission from Attila Nagy:

Python class Thread has a name argument, which sets the name of the given 
thread. This name is used only internally, while there is a possibility to set 
this on an OS-level.
Related discussion:
http://stackoverflow.com/questions/2369738/can-i-set-the-name-of-a-thread-in-pthreads-linux

#include pthread.h
int pthread_setname_np(pthread_t thread, const char *name);

// FreeBSD  OpenBSD: function name is slightly different
void pthread_set_name_np(pthread_t tid, const char *name);

// Mac OS X: it only seems applicable to the current thread (no thread ID)
int pthread_setname_np(const char*);

It would be very useful if Python set the name parameter with the above pthread 
calls, so the user/developer could see which threads do what in ps or top.

--
components: Library (Lib)
messages: 166890
nosy: bra
priority: normal
severity: normal
status: open
title: Python should support naming threads
type: enhancement
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-07-30 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
versions: +Python 3.4 -Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue15500] Python should support naming threads

2012-07-30 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue15500
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com