Strip trailing whitespace
This commit is contained in:
parent
874bc9b576
commit
c52d7181d6
@ -74,7 +74,7 @@ def func_timeout(timeout, func, args=(), kwargs=None):
|
|||||||
if isStopped is False:
|
if isStopped is False:
|
||||||
# Assemble the alternate traceback, excluding this function
|
# Assemble the alternate traceback, excluding this function
|
||||||
# from the trace (by going to next frame)
|
# from the trace (by going to next frame)
|
||||||
# Pytohn3 reads native from __traceback__,
|
# Pytohn3 reads native from __traceback__,
|
||||||
# python2 has a different form for "raise"
|
# python2 has a different form for "raise"
|
||||||
e.__traceback__ = exc_info[2].tb_next
|
e.__traceback__ = exc_info[2].tb_next
|
||||||
exception.append( e )
|
exception.append( e )
|
||||||
@ -120,34 +120,34 @@ def func_set_timeout(timeout, allowOverride=False):
|
|||||||
If #timeout is provided as a lambda/function, it will be called
|
If #timeout is provided as a lambda/function, it will be called
|
||||||
prior to each invocation of the decorated function to calculate the timeout to be used
|
prior to each invocation of the decorated function to calculate the timeout to be used
|
||||||
for that call, based on the arguments passed to the decorated function.
|
for that call, based on the arguments passed to the decorated function.
|
||||||
|
|
||||||
For example, you may have a "processData" function whose execution time
|
For example, you may have a "processData" function whose execution time
|
||||||
depends on the number of "data" elements, so you may want a million elements to have a
|
depends on the number of "data" elements, so you may want a million elements to have a
|
||||||
much higher timeout than seven elements.)
|
much higher timeout than seven elements.)
|
||||||
|
|
||||||
If #allowOverride is True AND a kwarg of "forceTimeout" is passed to the wrapped function, that timeout
|
If #allowOverride is True AND a kwarg of "forceTimeout" is passed to the wrapped function, that timeout
|
||||||
will be used for that single call.
|
will be used for that single call.
|
||||||
|
|
||||||
@param timeout <float OR lambda/function> -
|
@param timeout <float OR lambda/function> -
|
||||||
|
|
||||||
**If float:**
|
**If float:**
|
||||||
Default number of seconds max to allow function to execute
|
Default number of seconds max to allow function to execute
|
||||||
before throwing FunctionTimedOut
|
before throwing FunctionTimedOut
|
||||||
|
|
||||||
**If lambda/function:
|
**If lambda/function:
|
||||||
|
|
||||||
If a function/lambda is provided, it will be called for every
|
If a function/lambda is provided, it will be called for every
|
||||||
invocation of the decorated function (unless #allowOverride=True and "forceTimeout" was passed)
|
invocation of the decorated function (unless #allowOverride=True and "forceTimeout" was passed)
|
||||||
to determine the timeout to use based on the arguments to the decorated function.
|
to determine the timeout to use based on the arguments to the decorated function.
|
||||||
|
|
||||||
The arguments as passed into the decorated function will be passed to this function.
|
The arguments as passed into the decorated function will be passed to this function.
|
||||||
They either must match exactly to what the decorated function has, OR
|
They either must match exactly to what the decorated function has, OR
|
||||||
if you prefer to get the *args (list of ordered args) and **kwargs ( key : value keyword args form),
|
if you prefer to get the *args (list of ordered args) and **kwargs ( key : value keyword args form),
|
||||||
define your calculate function like:
|
define your calculate function like:
|
||||||
|
|
||||||
def calculateTimeout(*args, **kwargs):
|
def calculateTimeout(*args, **kwargs):
|
||||||
...
|
...
|
||||||
|
|
||||||
or lambda like:
|
or lambda like:
|
||||||
|
|
||||||
calculateTimeout = lambda *args, **kwargs : ...
|
calculateTimeout = lambda *args, **kwargs : ...
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class FunctionTimedOut(BaseException):
|
|||||||
retry - Retry the timed-out function with same arguments.
|
retry - Retry the timed-out function with same arguments.
|
||||||
|
|
||||||
@param timeout <float/RETRY_SAME_TIMEOUT/None> Default RETRY_SAME_TIMEOUT
|
@param timeout <float/RETRY_SAME_TIMEOUT/None> Default RETRY_SAME_TIMEOUT
|
||||||
|
|
||||||
If RETRY_SAME_TIMEOUT : Will retry the function same args, same timeout
|
If RETRY_SAME_TIMEOUT : Will retry the function same args, same timeout
|
||||||
If a float/int : Will retry the function same args with provided timeout
|
If a float/int : Will retry the function same args with provided timeout
|
||||||
If None : Will retry function same args no timeout
|
If None : Will retry function same args no timeout
|
||||||
@ -62,7 +62,7 @@ class FunctionTimedOut(BaseException):
|
|||||||
'''
|
'''
|
||||||
if timeout is None:
|
if timeout is None:
|
||||||
return self.timedOutFunction(*(self.timedOutArgs), **self.timedOutKwargs)
|
return self.timedOutFunction(*(self.timedOutArgs), **self.timedOutKwargs)
|
||||||
|
|
||||||
from .dafunc import func_timeout
|
from .dafunc import func_timeout
|
||||||
|
|
||||||
if timeout == RETRY_SAME_TIMEOUT:
|
if timeout == RETRY_SAME_TIMEOUT:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user