Many attempts have been made in the past to add timeout functionality in Python such that when a specified time limit expired, waiting code could move on. Unfortunately, pre
This is how to get the decorator syntax Jerub mentioned
def timeout(limit=None): if limit is None: limit = DEFAULT_TIMEOUT if limit <= 0: raise TimeoutError() # why not ValueError here? def wrap(function): return _Timeout(function,limit) return wrap @timeout(15) def mymethod(): pass