Thread-ID - how much could be?

Peter Otten __peter__ at
Sat Sep 13 09:48:05 CEST 2014

dieter wrote:

> Ervin Hegedüs <airween at> 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/ 
                    _sys.stderr.write("Exception in thread %s:\n%s\n" %
                            "Exception in thread " + +

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/
_counter = 0
def _newname(template="Thread-%d"):
    global _counter
    _counter += 1
    return template % _counter

More information about the Python-list mailing list