docs: def flush(self, models=None, wait=3.0):
          """Send all pending signals over the message bus.
  
          :param models: If passed, flushes only signals of the specified types.
          :type models: list(`signal-model`) or `None`
          :param float wait: The number of seconds the method will wait
              after obtaining the list of pending signals, to allow
              concurrent senders to complete
          :return: The total number of signals that have been sent
  
          """
  
          models_to_flush = self.get_signal_models() if models is None else models
          pks_to_flush = {}
          try:
              for model in models_to_flush:
                  _raise_error_if_not_signal_model(model)
                  m = inspect(model)
                  pk_attrs = [m.get_property_by_column(c).class_attribute for c in m.primary_key]
                  pks_to_flush[model] = self.signal_session.query(*pk_attrs).all()
              self.signal_session.rollback()
              time.sleep(wait)
              return sum(
                  self._flush_signals_with_retry(model, pk_values_set=set(pks_to_flush[model]))
                  for model in models_to_flush
              )
          finally:
              self.signal_session.remove()