<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_mprocess(process, timeout):
 """Compatibility function for waiting on a process with a timeout. Raises TimeoutError when the timeout is reached. """

    if PY3:
        try:
            return process.wait(timeout=timeout)
        except subprocess.TimeoutExpired as exc:
            raise TimeoutError(str(exc))

    # On Python 2, simulate the timeout parameter and raise TimeoutError.
    start = time.time()
    while True:
        exit_code = process.poll()
        if exit_code is not None:
            return exit_code
        if time.time() - start > timeout:
            raise TimeoutError("Process %s timed out after %s seconds" %
                               (process.pid, timeout))
        time.sleep(0.05)