diff --git a/oslo_utils/eventletutils.py b/oslo_utils/eventletutils.py index b27bb1d3..5e4b4aa0 100644 --- a/oslo_utils/eventletutils.py +++ b/oslo_utils/eventletutils.py @@ -169,7 +169,7 @@ class _Event(object): def Event(): - if EVENTLET_AVAILABLE: + if is_monkey_patched("thread"): return _Event() else: return threading.Event() diff --git a/oslo_utils/tests/test_eventletutils.py b/oslo_utils/tests/test_eventletutils.py index 811cd89c..e5765c72 100644 --- a/oslo_utils/tests/test_eventletutils.py +++ b/oslo_utils/tests/test_eventletutils.py @@ -125,10 +125,11 @@ class EventletUtilsTest(test_base.BaseTestCase): @mock.patch('oslo_utils.eventletutils._Event.clear') def test_event_api_compat(self, mock_clear): - e_event = eventletutils.Event() + with mock.patch('oslo_utils.eventletutils.is_monkey_patched', + return_value=True): + e_event = eventletutils.Event() self.assertIsInstance(e_event, eventletutils._Event) - eventletutils.EVENTLET_AVAILABLE = False t_event = eventletutils.Event() if six.PY3: t_event_cls = threading.Event