Manu
unread,Oct 18, 2011, 9:26:52 AM10/18/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cherrypy-devel
Hi,
I am using cherrypy 3.2.0 to dispatch requests to my own WSGI
applications. I am not at all an expert in cherrypy.
in cherrpy/__init__.py :
The threadlocal _Serving object's docstring says that it's a
threadlocal container for request and response. However, on
instantiation of this _Serving object (at serving = _Serving() ),
request and response seem to be set to class variables (e.g. one
request for all instances of the _Serving() object)
It seems that this object is not directly threadsafe, for example :
class T(threading.Thread):
def run(self):
print id(cherrypy.serving.request)
for t in xrange(10):
T().start()
will return always the same id.
What I think is happening is that the first call to load(request,
response) effectively sets self.response and self.request (and not
_Serving.request and _Serving.response) and makes it threadsafe.
I think the code might be clearer and more roboust with :
class _Serving(_local):
def __init__(self):
self.request = _Serving.request
self.response = _Serving.response
What do you think ?
Regards,
Manu