[Tutor] threading.currentThread() always same across request ?

Kent Johnson kent37 at tds.net
Sat Apr 14 19:39:13 CEST 2007


Andreas Kostyrka wrote:
> * Kent Johnson <kent37 at tds.net> [070414 19:30]:
>> Rather than store your attributes directly in the thread, it would 
>> probably be better to use a threading.local() object as the container.
>> http://docs.python.org/lib/module-threading.html#l2h-3416
>>
>> I don't really know if it makes any difference but this is the supported 
>> mechanism for thread-local storage.
> 
> Well, the other mechanism is also supported, because subclassing
> threads is allowed, and subclasses need to keep their attributes, even
> if accessed via threading.currentThread().

That's a good point. Does anyone know when to prefer threading.local() 
vs thread attributes?

Kent


More information about the Tutor mailing list