Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
351 views
in Technique[技术] by (71.8m points)

python - run web app with gevent

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...