Skip to content

Commit

Permalink
Test check_emergency_stop
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarago committed Feb 13, 2015
1 parent 738e77f commit bc4d9e2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions concert/tests/unit/test_sessions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""Test sessions."""
import time
from concert.quantities import q
from concert.session.utils import check_emergency_stop
from concert.tests import suppressed_logging, slow


@slow
@suppressed_logging
def test_check_emergency_stop():
class Callable(object):
abort = True
num_called = 0

def __call__(self):
was = self.abort
if self.num_called < 2:
# Called enough times to abort and clear
self.abort = not was

self.num_called += 1

return was

clb = Callable()
check_emergency_stop(clb, poll_interval=1*q.ms)
slept = 0
poll_interval = .1

while clb.num_called < 2:
time.sleep(poll_interval)
slept += poll_interval
# Don't get stuck
assert slept < 1

# We aborted and cleared, thus are ready to abort again.
assert clb.abort

0 comments on commit bc4d9e2

Please sign in to comment.