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