Exemplo n.º 1
0
 def run(self, runnable, args=None, kwargs=None):
     if self.error:
         raise DataError(self.error)
     if not self.active:
         raise FrameworkError('Timeout is not active')
     timeout = self.time_left()
     if timeout <= 0:
         raise TimeoutError(self.get_message())
     runner = ThreadedRunner(runnable, args, kwargs)
     if runner.run_in_thread(timeout):
         return runner.get_result()
     try:
         runner.stop_thread()
     except:
         raise TimeoutError('Stopping keyword after %s failed: %s' %
                            (self.type.lower(), utils.get_error_message()))
     raise TimeoutError(self._get_timeout_error())
Exemplo n.º 2
0
 def execute(self, runnable):
     runner = Runner(runnable)
     thread = Thread(ThreadStart(runner))
     thread.IsBackground = True
     thread.Start()
     if not thread.Join(self._timeout * 1000):
         thread.Abort()
         raise TimeoutError(self._error)
     return runner.get_result()
Exemplo n.º 3
0
 def execute(self, runnable):
     runner = Runner(runnable)
     thread = Thread(runner, name='RobotFrameworkTimeoutThread')
     thread.setDaemon(True)
     thread.start()
     thread.join(int(self._timeout * 1000))
     if thread.isAlive():
         thread.stop()
         raise TimeoutError(self._error)
     return runner.get_result()
 def run(self, runnable, args=None, kwargs=None):
     if self.error:
         raise DataError(self.error)
     if not self.active:
         raise FrameworkError('Timeout is not active')
     timeout = self.time_left()
     if timeout <= 0:
         raise TimeoutError(self.get_message())
     executable = lambda: runnable(*(args or ()), **(kwargs or {}))
     return Timeout(timeout, self._timeout_error).execute(executable)
Exemplo n.º 5
0
 def run(self, runnable, args=None, kwargs=None):
     if self.error:
         raise DataError(self.error)
     if not self.active:
         raise FrameworkError('Timeout is not active')
     timeout = self.time_left()
     error = TimeoutError(self._timeout_error,
                          test_timeout=isinstance(self, TestTimeout))
     if timeout <= 0:
         raise error
     executable = lambda: runnable(*(args or ()), **(kwargs or {}))
     return Timeout(timeout, error).execute(executable)
Exemplo n.º 6
0
 def execute(self, runnable):
     try:
         self._start_timer()
         try:
             result = runnable()
         finally:
             self._cancel_timer()
         self._wait_for_raised_timeout()
         return result
     finally:
         if self._timeout_occurred:
             raise TimeoutError(self._error)
Exemplo n.º 7
0
 def execute(self, runnable):
     runner = ThreadedRunner(runnable)
     if runner.run_in_thread(self._timeout):
         return runner.get_result()
     runner.stop_thread()
     raise TimeoutError(self._error)
Exemplo n.º 8
0
 def log_message(self, message):
     if self.timeout:
         self.timeout = False
         raise TimeoutError('Emulated timeout inside log_message')
Exemplo n.º 9
0
 def _raise_timeout_error(self, signum, frame):
     raise TimeoutError(self._error)