Ensure glance-api application is "greened"

Fixes bug 1052640

Avoid unresponsiveness during long-lived I/O-bound operations by
ensuring that the standard socket libraries are monkey-patched in
all code-paths.

Change-Id: If672c26f2b462d1abcfc86e20256957f73f98fde
This commit is contained in:
Eoghan Glynn 2012-09-19 11:37:28 +01:00
parent 923b901f85
commit 8f42dacecd

View File

@ -193,7 +193,7 @@ class Server(object):
if CONF.workers == 0:
# Useful for profiling, test, debug etc.
self.pool = eventlet.GreenPool(size=self.threads)
self.pool = self.create_pool()
self.pool.spawn_n(self._single_run, self.app_func(), self.sock)
return
else:
@ -204,6 +204,10 @@ class Server(object):
while len(self.children) < CONF.workers:
self.run_child()
def create_pool(self):
eventlet.patcher.monkey_patch(all=False, socket=True)
return eventlet.GreenPool(size=self.threads)
def wait_on_children(self):
while self.running:
try:
@ -266,8 +270,7 @@ class Server(object):
except Exception:
msg = _("eventlet 'poll' hub is not available on this platform")
raise exception.WorkerCreationFailure(reason=msg)
eventlet.patcher.monkey_patch(all=False, socket=True)
self.pool = eventlet.GreenPool(size=self.threads)
self.pool = self.create_pool()
try:
eventlet.wsgi.server(self.sock, self.app_func(),
log=WritableLogger(self.logger), custom_pool=self.pool)