Nick Coghlan added the comment:

It depends on the scope of uniqueness we're after. `threading._counter()` 
(which is the small-integer-ID debugging counter for threading.Thread names) is 
a module global in the threading module, so an Initialize/Finalize cycle will 
reset it.

If we wanted to track "Which Initialize/Finalize cycle is this?" *as well*, it 
would make more sense to me to have that as a separate "runtime" counter, such 
that the full coordinates of the current point of execution were:

- runtime counter (How many times has Py_Initialize been called?)
- interpreter counter (Which interpreter is currently active?)
- thread name (Which thread is currently active?)

I'll also note that in the threading module, the main thread is implicitly 
thread 0 (but named as MainThread) - Thread-1 is the first thread created via 
threading.Thread. So it may make sense to use a signed numeric ID, with 0 being 
the main interpreter, 1 being the first subinterpreter, and negative IDs being 
errors.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29102>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to