<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(self, timeout_ms=None):
 """Block until this command has completed. Args: timeout_ms: Timeout, in milliseconds, to wait. Returns: Output of the command if it complete and self.stdout is a StringIO object or was passed in as None. Returns True if the command completed but stdout was provided (and was not a StringIO object). Returns None if the timeout expired before the command completed. Be careful to check the return value explicitly for None, as the output may be ''. """

    closed = timeouts.loop_until_timeout_or_true(
        timeouts.PolledTimeout.from_millis(timeout_ms),
        self.stream.is_closed, .1)
    if closed:
      if hasattr(self.stdout, 'getvalue'):
        return self.stdout.getvalue()
      return True
    return None