diff options
author | Ben Nemec <bnemec@redhat.com> | 2018-11-01 16:24:45 +0000 |
---|---|---|
committer | Ben Nemec <bnemec@redhat.com> | 2018-11-01 20:53:53 +0000 |
commit | fde490f22d2ed3aacd0590e051b2722cb071d4bd (patch) | |
tree | 3ef53f9fb19716b76b0a22fcf8016cad08cf61c4 | |
parent | c568717706b18eab1c679c6792b8016f5fbb9a35 (diff) | |
download | oslo-utils-fde490f22d2ed3aacd0590e051b2722cb071d4bd.tar.gz |
Expose eventlet Event wrapper class3.38.0
We have a need to use the eventlet Event class directly in
oslo.service. Currently it is copy-pasted from this project, but
we now have a duplicate bug due to that so let's just expose it so
one copy can be used in both places.
This should be safe as the class implements a stdlib interface so
we can't really alter the API, and it's not really private since
instances of it are returned to users.
Change-Id: If8e7a41f9fe5573a780f9faabdbaf1326631d37a
Related-Change: https://review.openstack.org/558879
Related-Bug: 1800879
-rw-r--r-- | oslo_utils/eventletutils.py | 5 | ||||
-rw-r--r-- | oslo_utils/tests/test_eventletutils.py | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/oslo_utils/eventletutils.py b/oslo_utils/eventletutils.py index 46d9ba7..e5d8822 100644 --- a/oslo_utils/eventletutils.py +++ b/oslo_utils/eventletutils.py @@ -140,13 +140,14 @@ def is_monkey_patched(module): return _patcher.is_monkey_patched(module) -class _Event(object): +class EventletEvent(object): """A class that provides consistent eventlet/threading Event API. This wraps the eventlet.event.Event class to have the same API as the standard threading.Event object. """ def __init__(self, *args, **kwargs): + super(EventletEvent, self).__init__() self.clear() def clear(self): @@ -173,6 +174,6 @@ class _Event(object): def Event(): if is_monkey_patched("thread"): - return _Event() + return EventletEvent() else: return threading.Event() diff --git a/oslo_utils/tests/test_eventletutils.py b/oslo_utils/tests/test_eventletutils.py index 8e71e81..d72d03a 100644 --- a/oslo_utils/tests/test_eventletutils.py +++ b/oslo_utils/tests/test_eventletutils.py @@ -128,7 +128,7 @@ class EventletUtilsTest(test_base.BaseTestCase): with mock.patch('oslo_utils.eventletutils.is_monkey_patched', return_value=True): e_event = eventletutils.Event() - self.assertIsInstance(e_event, eventletutils._Event) + self.assertIsInstance(e_event, eventletutils.EventletEvent) t_event = eventletutils.Event() if six.PY3: |