Exemplo n.º 1
0
def check_emergency_stop(check, poll_interval=0.1*q.s, exit_session=False):
    """
    check_emergency_stop(check, poll_interval=0.1*q.s, exit_session=False)
    If a callable *check* returns True abort is called. Then until it clears to False nothing is
    done and then the process begins again. *poll_interval* is the interval at which *check* is
    called. If *exit_session* is True the session exits when the emergency stop occurs.
    """
    while True:
        if check():
            futures = abort()
            LOG.error('Emergency stop')
            wait(futures)
            if exit_session:
                os.abort()
            while check():
                # Wait until the flag clears
                time.sleep(poll_interval.to(q.s).magnitude)
        time.sleep(poll_interval.to(q.s).magnitude)
Exemplo n.º 2
0
    def test_abort_all(self):
        devices = [self.device, MockDevice()]
        wait(abort(devices))

        for device in devices:
            self.assertTrue(device.aborted)