Unique thread ID

Diez B. Roggisch deets at nospam.web.de
Fri Jan 18 03:15:22 EST 2008


Benjamin schrieb:
> Is there a way to obtain a unique ID for the current thread? I have an
> object that I need to store local thread data in, and I don't want to
> use threading.local because each thread might have multiple instances
> of my object.

You can use the thread itself, it's usable as key (that's what 
threadlocals use for their implementation anyway)

But I don't understand your problem - all thread-local implementations I 
know of (is there a standard?) can be instantiated in each object and 
then offer a get/set method (keyed or not) - but without interfering 
with outher instances of themselves of course.


Diez



More information about the Python-list mailing list