Thread-ID - how much could be?

Peter Otten __peter__ at web.de
Sat Sep 13 03:48:05 EDT 2014


dieter wrote:

> Ervin Hegedüs <airween at gmail.com> writes:
>> ...
> What is used as thread id is platform dependent. Likely, it depends
> on the thread support of the underlying C libary (i.e. the
> operating system thread support).
> 
> Under Linux, thread ids seem to be addresses - i.e. very large
> integers.

$ grep "Exception in thread" /usr/lib/python3.4/threading.py 
                    _sys.stderr.write("Exception in thread %s:\n%s\n" %
                            "Exception in thread " + self.name +


I believe the "Thread-ID"s we are talking about are actually user-specified 
names attached Python's threading.Thread instances, not something on the OS 
level. These names default to

$ grep -i -A4 -B1 "def _newname" /usr/lib/python3.4/threading.py
_counter = 0
def _newname(template="Thread-%d"):
    global _counter
    _counter += 1
    return template % _counter






More information about the Python-list mailing list