thread-local data

Diez B. Roggisch deets at nospam.web.de
Fri Feb 6 13:13:05 EST 2009


Diez B. Roggisch schrieb:
> Emanuele D'Arrigo schrieb:
>> Hi everybody,
>>
>> Assuming a snippet such as:
>>
>> threadLocalData = threading.local()
>> threadLocalData.myDictionary = self.myDictionary
>>
>> is it correct to say that threadLocalData.myDictionary is NOT a thread-
>> local -copy- of self.myDictionary but it's actually pointing to the
>> same object?
> 
> Yes, it's pointing to the same object, and it thus makes the whole 
> purpose of threadlocal moot. Use a global.

Scratch the "use a global" - that's of course nonsense. Use 
self.myDictionary directly, or wherever the dict comes from.

Diez



More information about the Python-list mailing list