Home:ALL Converter>running cherrypy application on gevent wsgi server

running cherrypy application on gevent wsgi server

Ask Time:2011-02-22T10:44:41         Author:deecodameeko

Json Formatter

I have an existing cherrypy application but I want to know is if it's at all possible to run it on the gevent wsgi server. I imagine I can but I don't have access to a linux server to test out gevent and haven't been able to get it to run on my mac.

I'm under the impression this is possible since each side follows wsgi spec.

Has anyone tried this?

I guess an example would look like the following:

import cherrypy 
from gevent import wsgi

class Root(object):
     def index(self):
        return "hi!"
     index.exposed = True

app = cherrypy.tree.mount(Root(), '/')
wsgi.WSGIServer(('', 8088), app).serve_forever()

Author:deecodameeko,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/5073499/running-cherrypy-application-on-gevent-wsgi-server
Alex :

This example will work until you encounter greenlet switch inside cherrypy handlers ! So this will fail if you use gevent for asynchronous communication inside handlers. \n\ncherrypy uses global object for storing response and headers inside found inside cherrypy/__ init__.py:~350 :\n\n# Create request and response object (the same objects will be used\n# throughout the entire life of the webserver, but will redirect\n# to the \"serving\" object)\nrequest = _ThreadLocalProxy('request')\nresponse = _ThreadLocalProxy('response')\n\n\nIf you pause one request and gevent switches to processing next it will overwrite content-length header in global object and you will face strange errors on client side.",
2012-06-06T15:18:19
yy