docs: def _connect(self, timeout=None):
          '''
          Connect to a running IPCServer
          '''
          if isinstance(self.socket_path, int):
              sock_type = socket.AF_INET
              sock_addr = ('127.0.0.1', self.socket_path)
          else:
              sock_type = socket.AF_UNIX
              sock_addr = self.socket_path
  
          self.stream = None
          if timeout is not None:
              timeout_at = time.time() + timeout
  
          while True:
              if self._closing:
                  break
  
              if self.stream is None:
                  with salt.utils.asynchronous.current_ioloop(self.io_loop):
                      self.stream = IOStream(
                          socket.socket(sock_type, socket.SOCK_STREAM),
                      )
  
              try:
                  log.trace('IPCClient: Connecting to socket: %s', self.socket_path)
                  yield self.stream.connect(sock_addr)
                  self._connecting_future.set_result(True)
                  break
              except Exception as e:
                  if self.stream.closed():
                      self.stream = None
  
                  if timeout is None or time.time() > timeout_at:
                      if self.stream is not None:
                          self.stream.close()
                          self.stream = None
                      self._connecting_future.set_exception(e)
                      break
  
                  yield tornado.gen.sleep(1)