Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Guarantee that gevent patching is applied before loading the APP for …

…serve command
  • Loading branch information...
commit b5206c3e458d56b6a7fa06c9de36ded7a8764a29 1 parent b708de6
@amol- amol- authored
Showing with 14 additions and 7 deletions.
  1. +10 −5 gearbox/commands/serve.py
  2. +4 −2 setup.py
View
15 gearbox/commands/serve.py
@@ -832,16 +832,21 @@ def wsgiref_server_runner(wsgi_app, global_conf, **kw): # pragma: no cover
server.serve_forever()
# For paste.deploy server instantiation (egg:gearbox#gevent)
-def gevent_server_runner(wsgi_app, global_config, **kw):
+def gevent_server_factory(global_config, **kw):
from gevent import reinit
from gevent.wsgi import WSGIServer
from gevent.monkey import patch_all
- host = kw.get('host', '0.0.0.0')
- port = int(kw.get('port', 8080))
reinit()
patch_all(dns=False)
- print('Starting Gevent HTTP server on http://%s:%s' % (host, port))
- WSGIServer((host, port), wsgi_app).serve_forever()
+
+ host = kw.get('host', '0.0.0.0')
+ port = int(kw.get('port', 8080))
+
+ def _gevent_serve(wsgi_app):
+ print('Starting Gevent HTTP server on http://%s:%s' % (host, port))
+ WSGIServer((host, port), wsgi_app).serve_forever()
+
+ return _gevent_serve
# For paste.deploy server instantiation (egg:gearbox#cherrypy)
def cherrypy_server_runner(
View
6 setup.py
@@ -49,6 +49,8 @@
'paste.server_runner': [
'wsgiref = gearbox.commands.serve:wsgiref_server_runner',
'cherrypy = gearbox.commands.serve:cherrypy_server_runner',
- 'gevent = gearbox.commands.serve:gevent_server_runner'
- ]
+ ],
+ 'paste.server_factory': [
+ 'gevent = gearbox.commands.serve:gevent_server_factory',
+ ]
})
Please sign in to comment.
Something went wrong with that request. Please try again.