Exemple #1
0
  def timeout_retry_wrapper(*args, **kwargs):
    timeout = timeout_func(*args, **kwargs)
    retries = retries_func(*args, **kwargs)
    if pass_values:
      kwargs['timeout'] = timeout
      kwargs['retries'] = retries

    @functools.wraps(f)
    def impl():
      return f(*args, **kwargs)

    try:
      if timeout_retry.CurrentTimeoutThreadGroup():
        # Don't wrap if there's already an outer timeout thread.
        return impl()
      else:
        desc = '%s(%s)' % (f.__name__, ', '.join(
            itertools.chain(
                (str(a) for a in args),
                ('%s=%s' % (k, str(v)) for k, v in kwargs.iteritems()))))
        return timeout_retry.Run(
            impl, timeout, retries, desc=desc, retry_if_func=retry_if_func)
    except reraiser_thread.TimeoutError as e:
      raise device_errors.CommandTimeoutError(str(e)), None, (sys.exc_info()[2])
    except cmd_helper.TimeoutError as e:
      raise device_errors.CommandTimeoutError(
          str(e), output=e.output), None, (sys.exc_info()[2])
Exemple #2
0
    def _setMockXmlScreenshots(self, xml_docs):
        """Mock self.app._GetRootUiNode to load nodes from some test xml_docs.

    Each time the method is called it will return a UI node for each string
    given in |xml_docs|, or rise a time out error when the list is exhausted.
    """

        # pylint: disable=protected-access
        def get_mock_root_ui_node(value):
            if isinstance(value, Exception):
                raise value
            return app_ui._UiNode(self.device, element_tree.fromstring(value),
                                  self.app.package)

        xml_docs.append(device_errors.CommandTimeoutError('Timed out!'))

        self.app._GetRootUiNode = mock.Mock(
            side_effect=(get_mock_root_ui_node(doc) for doc in xml_docs))
Exemple #3
0
 def testPicklable_CommandTimeoutError(self):
     original = device_errors.CommandTimeoutError(
         'My fake command timed out :(')
     self.assertIsPicklable(original)