Search code examples
pythontornadoopenshift-origin

Non-blocking tornado instance on Openshift?


I am trying to create tornado webserver and quick start made me standard project of tornado, but according to documentation this configuration is blocking. I am new to non-blocking python.

I have this wsgi file that lies in root folder in my PAAS server

#!/usr/bin/env python
import os
import imp
import sys

#
# Below for testing only
#
if __name__ == '__main__':
    ip   = 'localhost'
    port = 8051
    zapp = imp.load_source('application', 'wsgi/application')

    from wsgiref.simple_server import make_server
    httpd = make_server(ip, port, zapp.application)
    httpd.serve_forever()

This is main handler file

#!/usr/bin/env python
import tornado.web

class MainHandler(tornado.web.RequestHandler):
     def get(self):
          self.render('index.html')

And Application folder contains this

# Put here yours handlers.
import tornado.wsgi
from . import handlers

handlers = [(r'/',MainHandler),]


application = tornado.wsgi.WSGIApplication(handlers, **settings)

In WSGI mode asynchronous methods are not supported

uses WSGI to deploy the python applications

Is it possible to configure python application on openshift to be fully non-blocking

Though i have seen project that seemed to work


Solution

  • If you are talking about OpenShift V2 (not V3 which uses Kubernetes/Docker), then you need to use the app.py file as described in: