<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def wait_for(timeout, func, *args, **kwargs):
 """Waits for a eventual result. Parameters timeout : int How much time to wait, in seconds. func : callable A function that returns ``crochet.EventualResult``. args : tuple, optional Arguments for ``func``. kwargs : dict, optional Keyword arguments for ``func``. Returns ------- out Given ``func`` result. Raises ------ corchet.TimeoutError """

    result = func(*args, **kwargs)
    try:
        return result.wait(timeout)
    except crochet.TimeoutError:
        result.cancel()
        raise