deploying tornado on Google App Engine -


i trying deploy python pricing module takes product details (string) argument, on gae. tornado wrapper working fine on localhost (localhost:8888/?q=) giving server error 500 on gae.

code in pricing-oop.py file:

class mainhandler(tornado.web.requesthandler):     def get(self):         q = self.get_query_argument("q")         res = pricing(q).pricing()         self.write(json.dumps(res))  def make_app():     return tornado.web.application([         (r"/", mainhandler),     ],debug=true)     if __name__ == '__main__':     pickleload()     app = make_app()     container = tornado.wsgi.wsgicontainer(app)     http_server = tornado.httpserver.httpserver(container)       http_server.listen(8888)     tornado.ioloop.ioloop.current().start() 

app.yaml file:

service: tornado runtime: python27 threadsafe: no  handlers: - url: /.*   script: pricing-oop.py 

the gcloud app logs tail follows:

2017-07-26 03:03:30 tornado[20170726t082447]  "get / http/1.1" 500 2017-07-26 03:03:30 tornado[20170726t082447]  "get /favicon.ico http/1.1" 500 2017-07-26 03:03:33 tornado[20170726t082447]  "get / http/1.1" 500 2017-07-26 03:03:34 tornado[20170726t082447]  "get /favicon.ico http/1.1" 500 

how correct this?

there few notes regarding deploying on google app engine in the tornado docs.

in particular, tornado application on gae must run wsgi application. cannot things open ports on local machine, , unfortunately prevents use of asynchronous aspects of tornado (which main driver using in first place).

in case, instead of creating httpserver yourself, should create wsgiadapter:

# pricing-oop.py # ... def make_app():     return tornado.web.application([         (r"/", mainhandler),     ],debug=false)  application = make_app() application = tornado.wsgi.wsgiadapter(application) 

you tell gae find application referencing in script directive of configuration file:

# app.yaml # ... handlers: - url: /.*   script: pricing-oop.application 

because "pure" wsgi application, need run in container. google cloud sdk includes development server in dev_appserver.py can used host app:

$ dev_appserver.py . # in directory containing app.yaml

that being done, can run same application code both locally , in gae instance.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -