简体   繁体   中英

Non Blocking calls using Tornado and Python Eve

I have a Eve Application with Tornado.

http_server = HTTPServer(WSGIContainer(app))
http_server.listen(5000)
IOLoop.instance().start()

I make a post call on of my API that takes a long time and sends a mail to the user when the process is done. How can I make the call non blocking so that the user do not have to wait.

Thanks DC

Eve is written in Flask so by design it's blocking code and there's no simple way to make it magically non-blocking. Running your eve project in tornado will not help either. You can however use gunicorn or hendrix which can fork your wsgi app, act like a proxy, and make it seem like your project is running in a non-blocking manner. But I recommend using an async/threaded task runner (something like celery ) to send the mail. This method will require you to rewrite your mailing functions using the task runner. I hope this helps, if not please provide some more examples of what your code does and maybe we can help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM