From 6f63d28d9b8727409fd982d5920846a942b6d43e Mon Sep 17 00:00:00 2001 From: Erno Kuvaja Date: Thu, 25 Jan 2018 16:16:22 +0000 Subject: [PATCH] Fix py27 eventlet issue <0.22.0 Closes-Bug: #1744824 Change-Id: Ib9f8a52136e25d1cb609d465ca5d859523d9acc6 --- glance/cmd/api.py | 6 ++++++ glance/cmd/registry.py | 6 ++++++ glance/cmd/scrubber.py | 6 ++++++ glance/tests/__init__.py | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/glance/cmd/api.py b/glance/cmd/api.py index 48d431c874..b071c30d6c 100644 --- a/glance/cmd/api.py +++ b/glance/cmd/api.py @@ -29,6 +29,12 @@ 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) diff --git a/glance/cmd/registry.py b/glance/cmd/registry.py index b5e3c5a70a..8e7180df90 100644 --- a/glance/cmd/registry.py +++ b/glance/cmd/registry.py @@ -28,6 +28,12 @@ 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) # If ../glance/__init__.py exists, add ../ to Python search path, so that diff --git a/glance/cmd/scrubber.py b/glance/cmd/scrubber.py index 8a39c32ec8..7179bb4a41 100644 --- a/glance/cmd/scrubber.py +++ b/glance/cmd/scrubber.py @@ -38,6 +38,12 @@ 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) diff --git a/glance/tests/__init__.py b/glance/tests/__init__.py index f38fdf8bd9..964def506b 100644 --- a/glance/tests/__init__.py +++ b/glance/tests/__init__.py @@ -28,4 +28,10 @@ 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()