En Fri, 18 Jan 2008 22:41:47 -0300, Benjamin <[EMAIL PROTECTED]> escribió:
> On Jan 18, 2:31 am, Christian Heimes <[EMAIL PROTECTED]> wrote: >> Benjamin wrote: >> > 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. >> >> threading.get_ident() but please use threading.local. Nobody is going to >> stop you if you use a list or dict in threading.local. > then, I have to figure out how to represent an instance of my object > in threading.local. (The data also won't be garbage collect when my > object is, will it?) I think the unique id is elegant in this case. I think you didn't get how threading.local works yet. It's a lot easier than you imply. Just store your instances as attributes of a threading.local object. You may use a list or dictionary if you want multiple instances. Read _threading_local.py, it contains a lot of examples. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list