'This method sleeps until self._user_paused is False.'

def _pause_and_stop(self):

    def analyze_state():
        if self._user_stopped:
            msg = 'The    user    stopped    the    scan.'
            raise ScanMustStopByUserRequest(msg)
        if (self._stop_exception is not None):
            raise self._stop_exception
    while self._user_paused:
        time.sleep(0.2)
        analyze_state()
    analyze_state()
