18 from robot.utils import Sortable, secs_to_timestr, timestr_to_secs, WINDOWS
19 from robot.errors import TimeoutError, DataError, FrameworkError
22 from .windows
import Timeout
24 from .posix
import Timeout
29 def __init__(self, timeout=None, variables=None):
45 self.
stringstring = variables.replace_string(self.
stringstring)
50 except (DataError, ValueError)
as err:
51 self.
secssecs = 0.000001
52 self.
errorerror = (
'Setting %s timeout failed: %s' % (self.type.lower(), err))
61 elapsed = time.time() - self.
starttimestarttime
64 return round(self.
secssecs - elapsed, 3)
69 def run(self, runnable, args=None, kwargs=None):
76 test_timeout=isinstance(self, TestTimeout))
79 executable =
lambda: runnable(*(args
or ()), **(kwargs
or {}))
80 return Timeout(timeout, error).execute(executable)
84 return '%s timeout not active.' % self.type
86 return '%s timeout %s active. %s seconds left.' \
91 _timeout_error = property
94 return '%s timeout %s exceeded.' % (self.type, self.
stringstring)
100 return bool(self.
stringstring
and self.
stringstring.upper() !=
'NONE')
120 _keyword_timeout_occurred =
False
122 def __init__(self, timeout=None, variables=None, rpa=False):
125 _Timeout.__init__(self, timeout, variables)
Can be used when the core framework goes to unexpected state.
Used when a test or keyword timeout occurs.
bool _keyword_timeout_occurred
def __init__(self, timeout=None, variables=None, rpa=False)
def any_timeout_occurred(self)
def set_keyword_timeout(self, timeout_occurred)
def run(self, runnable, args=None, kwargs=None)
def replace_variables(self, variables)
def __init__(self, timeout=None, variables=None)
def secs_to_timestr(secs, compact=False)
Converts time in seconds to a string representation.
def timestr_to_secs(timestr, round_to=3, accept_plain_values=True)
Parses time strings like '1h 10s', '01:00:10' and '42' and returns seconds.