func_timeout (version 3.0.1)
index

Copyright (c) 2016 Tim Savannah All Rights Reserved.
 
Licensed under the Lesser GNU Public License Version 3, LGPLv3. You should have recieved a copy of this with the source distribution as
LICENSE, otherwise it is available at https://github.com/kata198/func_timeout/LICENSE

 
Package Contents
       
StoppableThread
dafunc
exceptions

 
Classes
       
builtins.BaseException(builtins.object)
func_timeout.exceptions.FunctionTimedOut

 
class FunctionTimedOut(builtins.BaseException)
    FunctionTimedOut - Exception raised when a function times out
 
 
Method resolution order:
FunctionTimedOut
builtins.BaseException
builtins.object

Data descriptors defined here:
__weakref__
list of weak references to the object (if defined)

Methods inherited from builtins.BaseException:
__delattr__(self, name, /)
Implement delattr(self, name).
__getattribute__(self, name, /)
Return getattr(self, name).
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.
__reduce__(...)
helper for pickle
__repr__(self, /)
Return repr(self).
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
__setstate__(...)
__str__(self, /)
Return str(self).
with_traceback(...)
Exception.with_traceback(tb) --
set self.__traceback__ to tb and return self.

Data descriptors inherited from builtins.BaseException:
__cause__
exception cause
__context__
exception context
__dict__
__suppress_context__
__traceback__
args

 
Functions
       
func_timeout(timeout, func, args=(), kwargs=None)
func_timeout - Runs the given function for up to #timeout# seconds.
 
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 func <function> - The function to call
@param args    <tuple> - Any ordered 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
 
If the timeout is exceeded, FunctionTimedOut will be raised within the context of the called function every two seconds until it terminates,
but will not block the calling thread (a new thread will be created to perform the join). If possible, you should try/except FunctionTimedOut
to return cleanly, but in most cases it will 'just work'.
 
Be careful of code like:
def myfunc():
    while True:
        try:
            dosomething()
        except Exception:
            continue
 
because it will never terminate.
 
@return - The return value that #func# gives

 
Data
        __all__ = ('func_timeout', 'FunctionTimedOut')
__version_tuple__ = (3, 0, 1)