From 3c68e9f41bc42fc193704b4c0b5bce4f5ed909c3 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Wed, 16 Jan 2013 08:58:47 +1300 Subject: [PATCH] Remove extras dependency with a partial oslo sync. Only service.py and importutils.py have been synchronized. This change is a blocker for producing g-2 rpms Change-Id: I692a8f6c9948a7aa75a2f6db7657d6c72e09a772 --- docs/GettingStarted.rst | 8 -------- heat/openstack/common/importutils.py | 8 ++++++++ heat/openstack/common/service.py | 13 ++++++++++--- tools/pip-requires | 1 - 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/GettingStarted.rst b/docs/GettingStarted.rst index 61314849..faab1fdd 100644 --- a/docs/GettingStarted.rst +++ b/docs/GettingStarted.rst @@ -94,14 +94,6 @@ In the heat directory, run the install script:: sudo ./install.sh -Install heat pip dependency ---------------------------- - -Heat requires the extras module, which is not currently packaged for Fedora, so it is necessary to manually install it:: - - sudo yum install -y python-pip - sudo pip-python install extras - Download Fedora 17 DVD and copy it to libvirt images location ------------------------------------------------------------- diff --git a/heat/openstack/common/importutils.py b/heat/openstack/common/importutils.py index 2a28b455..9dec764f 100644 --- a/heat/openstack/common/importutils.py +++ b/heat/openstack/common/importutils.py @@ -57,3 +57,11 @@ def import_module(import_str): """Import a module.""" __import__(import_str) return sys.modules[import_str] + + +def try_import(import_str, default=None): + """Try to import a module and if it fails return default.""" + try: + return import_module(import_str) + except ImportError: + return default diff --git a/heat/openstack/common/service.py b/heat/openstack/common/service.py index 8b63785f..4b3ef901 100644 --- a/heat/openstack/common/service.py +++ b/heat/openstack/common/service.py @@ -27,17 +27,17 @@ import sys import time import eventlet -import extras import logging as std_logging from heat.openstack.common import cfg from heat.openstack.common import eventlet_backdoor from heat.openstack.common.gettextutils import _ +from heat.openstack.common import importutils from heat.openstack.common import log as logging from heat.openstack.common import threadgroup -rpc = extras.try_import('heat.openstack.common.rpc') +rpc = importutils.try_import('heat.openstack.common.rpc') CONF = cfg.CONF LOG = logging.getLogger(__name__) @@ -243,7 +243,10 @@ class ProcessLauncher(object): def _wait_child(self): try: - pid, status = os.wait() + # Don't block if no child processes have exited + pid, status = os.waitpid(0, os.WNOHANG) + if not pid: + return None except OSError as exc: if exc.errno not in (errno.EINTR, errno.ECHILD): raise @@ -275,6 +278,10 @@ 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(.01) continue while self.running and len(wrap.children) < wrap.workers: diff --git a/tools/pip-requires b/tools/pip-requires index 213b1e6f..76498c4e 100644 --- a/tools/pip-requires +++ b/tools/pip-requires @@ -12,7 +12,6 @@ PyCrypto>=2.1.0 boto>=2.4.0 eventlet>=0.9.17 -extras greenlet>=0.3.1 httplib2 iso8601>=0.1.4 -- 2.45.2