4

I have a basic application written in CherryPy. It looks somewhat like this:

import cherrypy

class API():
    @cherrypy.expose
    def index(self):
        return "<h3>Its working!<h3>"

if __name__ == '__main__':
    cherrypy.config.update({
        'server.socket_host': '127.0.0.1',
        'server.socket_port': 8082,
    })
    cherrypy.quickstart(API())

I would like to deploy this application with gunicorn, possibly with multiple workers. gunicorn starts when I run this in terminal

gunicorn -b localhost:8082 -w 4 test_app:API 

But everytime I try to access the default method, it gives an internal server error. However, running this standalone using CherryPy works.

Here is the error:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 130, in handle
    self.handle_request(listener, req, client, addr)
  File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/sync.py", line 171, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
TypeError: this constructor takes no arguments

I have a fairly large CherryPy application that I would like to deploy using gunicorn. Is there any to mix CherryPy and gunicorn?

Jyotiska
  • 255
  • 3
  • 15
  • 2
    As gunicorn is a WSGI server, you need to provide it a WSGI application entry point, that isn't what you are doing. Look at the CherryPy instructions on WSGI deployment to determine how to create a WSGI application entry point. http://cherrypy.readthedocs.org/en/latest/deploy.html#wsgi-servers – Graham Dumpleton Jun 06 '15 at 05:30

0 Answers0