1- import eventlet
1+ from gevent import monkey
22
3- eventlet . monkey_patch () # this has to be called before other imports or monkey patching doesn't happen
3+ monkey . patch_all () # this has to be called before other imports or monkey patching doesn't happen
44
55import os # noqa
66import socket # noqa
77import sys # noqa
88import traceback # noqa
99
10- import eventlet .debug as debug # noqa
1110import gunicorn # noqa
1211
13- # This will give us a better stack trace if blocking occurs (if True)
14- debug .hub_blocking_detection (False )
12+ # This will give us a better stack trace if
1513workers = 4
16- worker_class = "eventlet "
14+ worker_class = "gevent "
1715worker_connections = 256
1816bind = "0.0.0.0:{}" .format (os .getenv ("PORT" ))
1917statsd_host = "{}:8125" .format (os .getenv ("STATSD_HOST" ))
@@ -36,22 +34,3 @@ def on_exit(server):
3634
3735def worker_int (worker ):
3836 worker .log .info ("worker: received SIGINT {}" .format (worker .pid ))
39-
40-
41- def fix_ssl_monkeypatching ():
42- """
43- eventlet works by monkey-patching core IO libraries (such as ssl) to be non-blocking. However, there's currently
44- a bug: In the normal socket library it may throw a timeout error as a `socket.timeout` exception. However
45- eventlet.green.ssl's patch raises an ssl.SSLError('timed out',) instead. redispy handles socket.timeout but not
46- ssl.SSLError, so we solve this by monkey patching the monkey patching code to raise the correct exception type
47- :scream:
48-
49- https://github.com/eventlet/eventlet/issues/692
50- """
51- # this has probably already been called somewhere in gunicorn internals, however, to be sure, we invoke it again.
52- # eventlet.monkey_patch can be called multiple times without issue
53- eventlet .monkey_patch ()
54- eventlet .green .ssl .timeout_exc = socket .timeout
55-
56-
57- fix_ssl_monkeypatching ()
0 commit comments