Skip to content
Snippets Groups Projects
Commit c9cc0f55 authored by Damian Johnson's avatar Damian Johnson
Browse files

Wait for unit tests to consume events

On #27053 Dave's reported that even with a bumped sleep these new tests
occasionally fail for him. Sleeps within tests are a code stink so I really
should do something smarter anyway.

Waiting up to five seconds for unit tests to consume the events they emit. When
we run both our unit and integ tests the later performs heavy tests asychrously.
This tends to peg the CPU while running our unit tests, probably slowing things
down enough for them to fail occasionly for Dave.
parent bc06836e
Branches
Tags
No related merge requests found
......@@ -826,7 +826,14 @@ class TestControl(unittest.TestCase):
self.controller._event_queue.put(uncast_event)
self.controller._event_notice.set()
# doesn't seem necessary in practice, but since event processing is
# asynchronous giving it a tiny bit of time to get handled
# Wait for the event to get asynchronously consumed. This should happen
# right away, but if the system is bogged down it may take quite a few
# milliseconds.
time.sleep(0.03)
event_sent_at = time.time()
while not self.controller._event_queue.empty():
time.sleep(0.01)
if time.time() - event_sent_at > 5:
self.fail('Event did not get processed after five seconds')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment