code: def __send_run(self):
          
          while not self.__end.is_set():
              try:
                  with Connection(userid=self.__prefix + self.__epid,
                                  password=self.__passwd,
                                  virtual_host=self.__vhost,
                                  heartbeat=self.__heartbeat,
                                  connect_timeout=self.__socket_timeout,
                                  operation_timeout=self.__socket_timeout,
                                  ssl=self.__get_ssl_context(self.__sslca),
                                  host=self.__host) as conn,\
                          conn.channel(auto_encode_decode=False) as channel:
  
                      self.__send_channel = channel
                      self.__send_exc_clear(log_if_exc_set='reconnected')
                      self.__send_ready.set()
                      try:
                          self.__send_ready_callback(self.__send_exc_time)
  
                          while not self.__end.is_set():
                              with self.__send_lock:
                                  try:
                                      # deal with any incoming messages (AMQP protocol only, not QAPI)
                                      conn.drain_events(0)
                                  except (BlockingIOError, SocketTimeout):
                                      pass
                                  conn.heartbeat_tick()
                              # idle
                              self.__end.wait(.25)
                      finally:
                          # locked so can make sure another call to send() is not made whilst shutting down
                          with self.__send_lock:
                              self.__send_ready.clear()
  
              except exceptions.AccessRefused:
                  self.__send_log_set_exc_and_wait('Access Refused (Credentials already in use?)')
              except exceptions.ConnectionForced:
                  self.__send_log_set_exc_and_wait('Disconnected by broker (ConnectionForced)')
              except SocketTimeout:
                  self.__send_log_set_exc_and_wait('SocketTimeout exception.  wrong credentials, vhost or prefix?')
              except SSLError:
                  self.__send_log_set_exc_and_wait('ssl.SSLError Bad Certificate?')
              except (exceptions.AMQPError, SocketError):
                  self.__send_log_set_exc_and_wait('amqp/transport failure, sleeping before retry')
              except:
                  self.__send_log_set_exc_and_wait('unexpected failure, exiting', wait_seconds=0)
                  break
          logger.debug('finished')
docs: Send request thread