From 466cb128a7a03f4b1ea1ffa539498ae10adab000 Mon Sep 17 00:00:00 2001 From: abhishekkekane Date: Thu, 11 Sep 2014 23:39:41 -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. --- glance/common/wsgi.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glance/common/wsgi.py b/glance/common/wsgi.py index 99bd183..352ddf3 100644 --- a/glance/common/wsgi.py +++ b/glance/common/wsgi.py @@ -89,6 +89,9 @@ eventlet_opts = [ 'max_header_line may need to be increased when using ' 'large tokens (typically those generated by the ' 'Keystone v3 API with big service catalogs')), + cfg.BoolOpt('wsgi_keep_alive', default=True, + help=_('If False, closes the client socket connection ' + 'explicitly.')) ] profiler_opts = [ @@ -340,7 +343,8 @@ class Server(object): self.application, log=logging.WritableLogger(self.logger), custom_pool=self.pool, - debug=False) + debug=False, + keepalive=CONF.wsgi_keep_alive) except socket.error as err: if err[0] != errno.EINVAL: raise @@ -351,7 +355,7 @@ class Server(object): self.logger.info(_("Starting single process server")) eventlet.wsgi.server(sock, application, custom_pool=self.pool, log=logging.WritableLogger(self.logger), - debug=False) + debug=False, keepalive=CONF.wsgi_keep_alive) class Middleware(object): -- 1.9.1