Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix timeout in await state event

When state events that you are not expecting occur, await_state_event
can never time out
  • Loading branch information...
commit 0bcddf3675c4c8c0e4fffa94965c2e31901da1cd 1 parent fc4178e
@oldpatricka oldpatricka authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 ion/services/cei/test/__init__.py
View
5 ion/services/cei/test/__init__.py
@@ -1,4 +1,5 @@
from gevent import queue
+from datetime import datetime, timedelta
from pyon.event.event import EventSubscriber
from pyon.public import log
@@ -31,10 +32,14 @@ def await_state_event(self, pid=None, state=None, timeout=30, strict=False):
if strict is False, allow intermediary events
"""
+ start_time = datetime.now()
+
assert state in ProcessStateEnum._str_map, "process state %s unknown!" % state
state_str = ProcessStateEnum._str_map.get(state)
while 1:
+ if datetime.now() - start_time > timedelta(seconds=timeout):
+ raise AssertionError("Waiter timeout! Waited %s seconds for process %s state %s" % (timeout, pid, state_str))
try:
event = self.event_queue.get(timeout=timeout)
except queue.Empty:
Please sign in to comment.
Something went wrong with that request. Please try again.