Update docstring text

This commit is contained in:
Tim Savannah 2017-05-20 17:13:48 -04:00
parent d10476b734
commit e554cd0252
2 changed files with 10 additions and 4 deletions

View File

@ -27,10 +27,14 @@ def func_timeout(timeout, func, args=(), kwargs=None):
Raises any exceptions #func# would raise, returns what #func# would return (unless timeout is exceeded), in which case it raises FunctionTimedOut Raises any exceptions #func# would raise, returns what #func# would return (unless timeout is exceeded), in which case it raises FunctionTimedOut
@param timeout <float> - Maximum number of seconds to run #func# before terminating @param timeout <float> - Maximum number of seconds to run #func# before terminating
@param func <function> - The function to call @param func <function> - The function to call
@param args <tuple> - Any ordered arguments to pass to the function @param args <tuple> - Any ordered arguments to pass to the function
@param kwargs <dict/None> - Keyword arguments to pass to the function. @param kwargs <dict/None> - Keyword arguments to pass to the function.
@raises - FunctionTimedOut if #timeout# is exceeded, otherwise anything #func# could raise will be raised @raises - FunctionTimedOut if #timeout# is exceeded, otherwise anything #func# could raise will be raised
If the timeout is exceeded, FunctionTimedOut will be raised within the context of the called function every two seconds until it terminates, If the timeout is exceeded, FunctionTimedOut will be raised within the context of the called function every two seconds until it terminates,
@ -38,6 +42,7 @@ def func_timeout(timeout, func, args=(), kwargs=None):
to return cleanly, but in most cases it will 'just work'. to return cleanly, but in most cases it will 'just work'.
Be careful of code like: Be careful of code like:
def myfunc(): def myfunc():
while True: while True:
try: try:
@ -93,7 +98,7 @@ def func_timeout(timeout, func, args=(), kwargs=None):
def func_set_timeout(timeout, allowOverride=False): def func_set_timeout(timeout, allowOverride=False):
''' '''
set_timeout - Wrapper to run a function with a given/calculated timeout (max execution time). func_set_timeout - Decorator to run a function with a given/calculated timeout (max execution time).
Optionally (if #allowOverride is True), adds a paramater, "forceTimeout", to the Optionally (if #allowOverride is True), adds a paramater, "forceTimeout", to the
function which, if provided, will override the default timeout for that invocation. function which, if provided, will override the default timeout for that invocation.

View File

@ -7,7 +7,7 @@
__all__ = ('FunctionTimedOut', 'RETRY_SAME_TIMEOUT') __all__ = ('FunctionTimedOut', 'RETRY_SAME_TIMEOUT')
RETRY_SAME_TIMEOUT = '__rst' RETRY_SAME_TIMEOUT = 'RETRY_SAME_TIMEOUT'
class FunctionTimedOut(BaseException): class FunctionTimedOut(BaseException):
''' '''
@ -19,7 +19,8 @@ class FunctionTimedOut(BaseException):
@property timedOutArgs - Ordered args to function @property timedOutArgs - Ordered args to function
@property timedOutKwargs - Keyword args to function @property timedOutKwargs - Keyword args to function
@method retry - R @method retry - Retries the function with same arguments, with option to run with original timeout, no timeout, or a different
explicit timeout. @see FunctionTimedOut.retry
''' '''
@ -53,7 +54,7 @@ class FunctionTimedOut(BaseException):
@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, sane 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