Optimization of waiting subprocesses in ProcessLauncher
Because of eventlet bug "eventlet.green override of os.waitpid returns immediately in all cases"( https://bitbucket.org/eventlet/eventlet/issue/92/eventletgreen-override-of-oswaitpid) in scope of fixing openstack bug "Excessive CPU usage in ProcessLauncher()'s wait loop" (https://bugs.launchpad.net/oslo-incubator/+bug/109534) additional sleep was added. Since this bug is resolved and openstack depends on eventlet >=0.16 excessive sleep was removed. Change-Id: Ief30758ff429b4adc2265a8ed7ae34c5b8c60a34
This commit is contained in:
@@ -199,16 +199,12 @@ class ServiceWrapper(object):
|
||||
|
||||
|
||||
class ProcessLauncher(object):
|
||||
def __init__(self, wait_interval=0.01):
|
||||
"""Constructor.
|
||||
def __init__(self):
|
||||
"""Constructor."""
|
||||
|
||||
:param wait_interval: The interval to sleep for between checks
|
||||
of child process exit.
|
||||
"""
|
||||
self.children = {}
|
||||
self.sigcaught = None
|
||||
self.running = True
|
||||
self.wait_interval = wait_interval
|
||||
rfd, self.writepipe = os.pipe()
|
||||
self.readpipe = eventlet.greenio.GreenPipe(rfd, 'r')
|
||||
self.handle_signal()
|
||||
@@ -333,8 +329,8 @@ class ProcessLauncher(object):
|
||||
|
||||
def _wait_child(self):
|
||||
try:
|
||||
# Don't block if no child processes have exited
|
||||
pid, status = os.waitpid(0, os.WNOHANG)
|
||||
# Block while any of child processes have exited
|
||||
pid, status = os.waitpid(0, 0)
|
||||
if not pid:
|
||||
return None
|
||||
except OSError as exc:
|
||||
@@ -363,10 +359,6 @@ class ProcessLauncher(object):
|
||||
while self.running:
|
||||
wrap = self._wait_child()
|
||||
if not wrap:
|
||||
# Yield to other threads if no children have exited
|
||||
# Sleep for a short time to avoid excessive CPU usage
|
||||
# (see bug #1095346)
|
||||
eventlet.greenthread.sleep(self.wait_interval)
|
||||
continue
|
||||
while self.running and len(wrap.children) < wrap.workers:
|
||||
self._start_child(wrap)
|
||||
|
||||
Reference in New Issue
Block a user