diff --git a/glance/cmd/api.py b/glance/cmd/api.py index b071c30d6c..4ff5071288 100644 --- a/glance/cmd/api.py +++ b/glance/cmd/api.py @@ -20,23 +20,19 @@ """ Glance API Server """ - -import os -import sys - import eventlet -from oslo_utils import encodeutils - - -# Monkey patch socket, time, select, threads # NOTE(jokke): As per the eventlet commit # b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening # which can be solved making sure the hubs are properly and fully imported # before calling monkey_patch(). This is solved in eventlet 0.22.0 but we # need to address it before that is widely used around. eventlet.hubs.get_hub() -eventlet.patcher.monkey_patch(all=False, socket=True, time=True, - select=True, thread=True, os=True) +eventlet.patcher.monkey_patch() + +import os +import sys + +from oslo_utils import encodeutils # If ../glance/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... diff --git a/glance/cmd/registry.py b/glance/cmd/registry.py index 8e7180df90..929f825ec1 100644 --- a/glance/cmd/registry.py +++ b/glance/cmd/registry.py @@ -20,21 +20,20 @@ """ Reference implementation server for Glance Registry """ - -import os -import sys - import eventlet -from oslo_utils import encodeutils - -# Monkey patch socket and time # NOTE(jokke): As per the eventlet commit # b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening # which can be solved making sure the hubs are properly and fully imported # before calling monkey_patch(). This is solved in eventlet 0.22.0 but we # need to address it before that is widely used around. eventlet.hubs.get_hub() -eventlet.patcher.monkey_patch(all=False, socket=True, time=True, thread=True) +eventlet.patcher.monkey_patch() + +import os +import sys + + +from oslo_utils import encodeutils # If ../glance/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... diff --git a/glance/cmd/scrubber.py b/glance/cmd/scrubber.py index 7179bb4a41..4abfce537e 100644 --- a/glance/cmd/scrubber.py +++ b/glance/cmd/scrubber.py @@ -18,6 +18,14 @@ """ Glance Scrub Service """ +import eventlet +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() +eventlet.patcher.monkey_patch() import os import sys @@ -29,7 +37,6 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), os.pardir)) if os.path.exists(os.path.join(possible_topdir, 'glance', '__init__.py')): sys.path.insert(0, possible_topdir) -import eventlet import glance_store from oslo_config import cfg @@ -38,14 +45,6 @@ from oslo_log import log as logging from glance.common import config from glance import scrubber -# NOTE(jokke): As per the eventlet commit -# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening -# which can be solved making sure the hubs are properly and fully imported -# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we -# need to address it before that is widely used around. -eventlet.hubs.get_hub() -eventlet.patcher.monkey_patch(all=False, socket=True, time=True, select=True, - thread=True, os=True) CONF = cfg.CONF logging.register_options(CONF) diff --git a/glance/tests/__init__.py b/glance/tests/__init__.py index 964def506b..724b7e982c 100644 --- a/glance/tests/__init__.py +++ b/glance/tests/__init__.py @@ -13,6 +13,15 @@ # License for the specific language governing permissions and limitations # under the License. +import eventlet +# NOTE(jokke): As per the eventlet commit +# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening +# which can be solved making sure the hubs are properly and fully imported +# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we +# need to address it before that is widely used around. +eventlet.hubs.get_hub() +eventlet.patcher.monkey_patch() + # See http://code.google.com/p/python-nose/issues/detail?id=373 # The code below enables tests to work with i18n _() blocks import six.moves.builtins as __builtin__ @@ -26,12 +35,3 @@ formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) logger.addHandler(hdlr) logger.setLevel(logging.DEBUG) - -import eventlet -# NOTE(jokke): As per the eventlet commit -# b756447bab51046dfc6f1e0e299cc997ab343701 there's circular import happening -# which can be solved making sure the hubs are properly and fully imported -# before calling monkey_patch(). This is solved in eventlet 0.22.0 but we -# need to address it before that is widely used around. -eventlet.hubs.get_hub() -eventlet.patcher.monkey_patch()