run web app with gevent

拜拜、爱过 提交于 2019-11-27 13:52:29

问题


I want to try playing around with gevent as a web server and application framework. I don't see any way to "restart" the server or update the application code without killing and starting the whole python application again.

Is this just how it's done? Maybe it's just a matter of me understanding a different paradigm to the apache way.

Also, as a semi-related question, is it even a good idea to run a web server AND the site/service itself through gevent. I've seen other implementations using gunicorn for the server and gevent for the application but from the benchmarks I've seen, gevent far outperforms gunicorn as a server when it comes to scaling.


回答1:


Gunicorn has 3 gevent workers:

  • -k gevent (using gunicorn's HTTP parser)
  • -k gevent_pywsgi (using gevent.pywsgi module)
  • -k gevent_wsgi (using gevent.wsgi module)

gevent.wsgi is a fast HTTP server based on libevent.

gevent.pywsgi is WSGI server implemented in Python.

The reason for existence of gevent.pywsgi is libevent-http having a few limitations, such as not supporting keep-alive, streaming, ssl and websockets.

Note, that the new alpha version (1.0a3) of gevent uses libev and does not include a WSGI server based on libevent-http. Currently, gevent.wsgi here is an alias for gevent.pywsgi.

The server classes in gevent don't have any features related to process management, restart, reload and so on. Those features are necessary for deployment though. Gunicorn provides that for gevent's WSGI servers. Use it.



来源:https://stackoverflow.com/questions/7855343/run-web-app-with-gevent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!