mardi 24 juillet 2018

How to reach the aim of asynchronous request in the Tornado web service

Question: i set up a web service based on tonardo for my model. And as the request Concurrency increases, the web will easily turn down.

What i have tried: i have already tried to read some relevant code like the asynchronous framework in tornado, but i can't get the effective ideas.

The web service code as follows:

class mainhandler(tornado.web.RequestHandler):
    def get(self):
        self.write('hello')

    def post(self):
        in_data = json.loads(self.request.body.decode('utf-8'))
        res = predict(in_data)
    def set_default_headers(self):
        self.set_header('content_type', 'application/json;charset=utf-8')

application = tornado.web.Application([(r'/', mainhandler)])

if __name__ == "__main__":
    application.listen(port=5000)
    tornado.ioloop.IOloop.current().start()




Aucun commentaire:

Enregistrer un commentaire