#NEWLINE# def TakeAtMostNSeconds( time_s , func , * args , **kwargs ) : #NEWLINE# #INDENT# 'A function that returns whether a function call took less than time_s.\n\n  NOTE: The function call is not killed and will run indefinitely if hung.\n\n  Args:\n    time_s: Maximum amount of time to take.\n    func: Function to call.\n    *args: Arguments to call the function with.\n    **kwargs: Keyword arguments to call the function with.\n  Returns:\n    True if the function finished in less than time_s seconds.\n  ' #NEWLINE# thread = threading . Thread ( target = time_s , args = args , kwargs = kwargs ) #NEWLINE# thread . start ( ) #NEWLINE# thread . join ( time_s ) #NEWLINE# if thread . is_alive ( ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# return True