code: def _wait_for_connection_state(self, state=Stateful.OPEN, rpc_timeout=30):
          
          start_time = time.time()
          while self.current_state != state:
              self.check_for_errors()
              if time.time() - start_time > rpc_timeout:
                  raise AMQPConnectionError('Connection timed out')
              sleep(IDLE_WAIT)
docs: Wait for a Connection state.
  
          :param int state: State that we expect
  
          :raises AMQPConnectionError: Raises if we are unable to establish
                                       a connection to RabbitMQ.
  
          :return: