From 4c30b26c2ae9613b503160788636d7786af458b3 Mon Sep 17 00:00:00 2001 From: abhishekkekane Date: Thu, 11 Sep 2014 23:57:15 -0700 Subject: [PATCH] Eventlet green threads not released back to pool Presently, the wsgi server allows persist connections hence even after the response is sent to the client, it doesn't close the client socket connection. Because of this problem, the green thread is not released back to the pool. In order to close the client socket connection explicitly after the response is sent and read successfully by the client, you simply have to set keepalive to False when you create a wsgi server. DocImpact: Added wsgi_keep_alive option (default=True). In order to close the client socket connection explicitly after the response is sent and read successfully by the client, set wsgi_keep_alive to False. --- keystone/common/environment/eventlet_server.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/keystone/common/environment/eventlet_server.py b/keystone/common/environment/eventlet_server.py index fa6d58f..de06742 100644 --- a/keystone/common/environment/eventlet_server.py +++ b/keystone/common/environment/eventlet_server.py @@ -25,6 +25,7 @@ import sys import eventlet import eventlet.wsgi import greenlet +from oslo.config import cfg from keystone.i18n import _ from keystone.i18n import _LE @@ -32,6 +33,16 @@ from keystone.i18n import _LI from keystone.openstack.common import log +eventlet_opts = [ + cfg.BoolOpt('wsgi_keep_alive', default=True, + help=_("If False, closes the client socket connection " + "explicitly.")) +] + +CONF = cfg.CONF +CONF.register_opts(eventlet_opts) + + LOG = log.getLogger(__name__) @@ -179,7 +190,7 @@ class Server(object): try: eventlet.wsgi.server(socket, application, custom_pool=self.pool, log=EventletFilteringLogger(logger), - debug=False) + debug=False, keepalive=CONF.wsgi_keep_alive) except greenlet.GreenletExit: # Wait until all servers have completed running pass -- 1.9.1