Merge "Avoid calling eventlet.event.Event.reset()"
This commit is contained in:
commit
eff0629790
|
@ -165,11 +165,9 @@ class EventletEvent(object):
|
||||||
isSet = is_set
|
isSet = is_set
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
if self._set:
|
if not self._set:
|
||||||
self._event.reset()
|
self._set = True
|
||||||
|
self._event.send(True)
|
||||||
self._set = True
|
|
||||||
self._event.send(True)
|
|
||||||
|
|
||||||
def wait(self, timeout=None):
|
def wait(self, timeout=None):
|
||||||
with timeutils.StopWatch(timeout) as sw:
|
with timeutils.StopWatch(timeout) as sw:
|
||||||
|
|
|
@ -146,12 +146,11 @@ class EventletUtilsTest(test_base.BaseTestCase):
|
||||||
self.assertTrue(hasattr(e_event, method))
|
self.assertTrue(hasattr(e_event, method))
|
||||||
|
|
||||||
# Ensure set() allows multiple invocations, same as in
|
# Ensure set() allows multiple invocations, same as in
|
||||||
# threading implementation. Must call reset on underlying
|
# threading implementation.
|
||||||
# Event before reusing it
|
|
||||||
e_event.set()
|
e_event.set()
|
||||||
self.assertEqual(0, mock_eventlet.event.Event().reset.call_count)
|
self.assertTrue(e_event.isSet())
|
||||||
e_event.set()
|
e_event.set()
|
||||||
self.assertEqual(1, mock_eventlet.event.Event().reset.call_count)
|
self.assertTrue(e_event.isSet())
|
||||||
|
|
||||||
def test_event_no_timeout(self):
|
def test_event_no_timeout(self):
|
||||||
event = eventletutils.EventletEvent()
|
event = eventletutils.EventletEvent()
|
||||||
|
|
Loading…
Reference in New Issue