[issue2871] store thread.get_ident() thread identifier inside threading.Thread objects

Antoine Pitrou report at bugs.python.org
Fri May 23 17:29:44 CEST 2008


Antoine Pitrou <pitrou at free.fr> added the comment:

> Currently, when creating a new Thread object, there is no good way of
> getting that thread's get_ident() value. 

Well, how about doing it at the beginning of its run() method, e.g. in a
Thread subclass:

    class MyThread(threading.Thread):
        def run(self):
            self.thread_ident = thread.get_ident()
            threading.Thread.run(self) # or any other stuff


Also, I don't think get_ident() is often useful when using the Threading
module, since you can just use the id() of the current Thread object
instead.

----------
nosy: +pitrou

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2871>
__________________________________


More information about the Python-bugs-list mailing list