diff --git a/func_timeout/dafunc.py b/func_timeout/dafunc.py index d732d8d..524f758 100644 --- a/func_timeout/dafunc.py +++ b/func_timeout/dafunc.py @@ -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 @param timeout - Maximum number of seconds to run #func# before terminating + @param func - The function to call + @param args - Any ordered arguments to pass to the function + @param kwargs - Keyword arguments to pass to the function. + @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, @@ -38,6 +42,7 @@ def func_timeout(timeout, func, args=(), kwargs=None): to return cleanly, but in most cases it will 'just work'. Be careful of code like: + def myfunc(): while True: try: @@ -93,7 +98,7 @@ def func_timeout(timeout, func, args=(), kwargs=None): 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 function which, if provided, will override the default timeout for that invocation. diff --git a/func_timeout/exceptions.py b/func_timeout/exceptions.py index 62c55ab..d6a9b45 100644 --- a/func_timeout/exceptions.py +++ b/func_timeout/exceptions.py @@ -7,7 +7,7 @@ __all__ = ('FunctionTimedOut', 'RETRY_SAME_TIMEOUT') -RETRY_SAME_TIMEOUT = '__rst' +RETRY_SAME_TIMEOUT = 'RETRY_SAME_TIMEOUT' class FunctionTimedOut(BaseException): ''' @@ -19,7 +19,8 @@ class FunctionTimedOut(BaseException): @property timedOutArgs - Ordered 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 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 None : Will retry function same args no timeout