I have a django app and I decided that I needed gevent so the webserver does not block on long connections.

I am not using websockets - just a simple app. I can use gevent with gunicorn like so:

gunicorn -k gevent -c config.py -b :9999 app:app

In my app, I do not have anything like the following code in manage.py:

monkey.patch_all()

When do I need to use the monkey patch? How come the app works fine without this change?

有帮助吗?

解决方案

Monkey patching from Gevent is used when you have python code/modules that uses blocking functions from standard library. For example you have existing code that uses threading and urllib2 modules to download several pages concurrently and you want to use that code from gunicorn.

Note that proper way to use threads with greenlets is by ThreadPool.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top