On Aug 22, 2007, at 6:46 AM, pstradomski wrote:

Routes tries to be thread-safe - it even provides special thread-local
storage for data from the web framework. Nevertheless in __init__.py,
in load_wsgi_environ() there is: self.mapper.environ = environ.

That way the thread-safety is broken - it is impossible to correctly
use one mapper for all threads. Do I correctly see this as a bug? In
my opinion thread-safe RoutesConfig should not make any modifications
to mapper object, but instead mapper should query RoutesConfig for
environment data when needed.

That's somewhat deceptive, but it is actually threadsafe. From the mappers __init__:
        self.req_data = threadinglocal.local()

And the mapper.environ attribute is a property that looks like this:
    def _envget(self):
        return getattr(self.req_data, 'environ', None)
    def _envset(self, env):
        self.req_data.environ = env
    def _envdel(self):
        del self.req_data.environ
    environ = property(_envget, _envset, _envdel)

So setting environ actually is setting req_data, which is a thread local.

Cheers,
Ben

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to