human
I wrote the below code

    class TimeoutThread(threading.Thread, ):
        def __init__(self):
            threading.Thread.__init__(self)
            self.result = None
            self.exc_info = None
            self.daemon = True
        def run(self):
            try:
                self.result = func(*args, **kwargs)
            except BaseException:
                self.exc_info = sys.exc_info()
        def raise_async_timeout(self):
            tid = ctypes.c_long(self.ident)
            result = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(TimeoutExpired))
            if (result > 1):
                ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
    thread = TimeoutThread()
    thread.start()
    thread.join(timeout)
    if thread.is_alive():
        for i in range(10):
            thread.raise_async_timeout()
            time.sleep(0.1)
            if (not thread.is_alive()):
                break
        raise TimeoutExpired
    if thread.exc_info:
        six.reraise(thread.exc_info[0], thread.exc_info[1], thread.exc_info[2])
    assert (thread.result is not None)
    return thread.result

What's a good function header?
assistant
#Here's a good function header.

def timeout(timeout, func, *args, **kwargs):