[mod_python] Using threading.local with Worker MPM

Gavin Panella gavin at premolo.com
Thu Aug 17 02:39:52 EDT 2006


> Not that it will matter, but where are you storing the thread local
> variable? Is that in a module that can be reloaded automatically by
> mod_python?

I create the shared space object at module level, but that module is not 
loaded directly by mod_python, so I don't think it would be reloaded.

The space object is a wrapper around a dict-like object, LocalData, which is a 
subclass of threading.local. This intercepts __(get|set|del)item__ calls, 
which are then directed straight at self.__dict__ (so that I can have keys 
that are not valid identifiers).

Thing is, during a request, the id of the space object remains constant, as 
does the id of the LocalData instance (the space object holds a reference to 
it). The only thing that I have seen change so far is the id of the __dict__ 
on the LocalData instance.

I'll try and get up-to-date with mod_python and see if that helps.

Cheerio, Gavin.

-- 
Premolo Sàrl
Web: http://www.premolo.com/ ; Tel: +352 26687161 ; GSM: +352 091739359
42 rue du Kiem, L-1857 Luxembourg, Grand-Duché du Luxembourg



More information about the Mod_python mailing list