code: def wait(self):
          
          if self.error:
              raise self.error
          if not self.running:
              raise ValueError("Unable to send until client has been started.")
          try:
              self._handler.wait()
          except (errors.TokenExpired, errors.AuthenticationException):
              log.info("Sender disconnected due to token error. Attempting reconnect.")
              self.reconnect()
          except (errors.LinkDetach, errors.ConnectionClose) as shutdown:
              if shutdown.action.retry and self.auto_reconnect:
                  log.info("Sender detached. Attempting reconnect.")
                  self.reconnect()
              else:
                  log.info("Sender detached. Shutting down.")
                  error = EventHubError(str(shutdown), shutdown)
                  self.close(exception=error)
                  raise error
          except errors.MessageHandlerError as shutdown:
              if self.auto_reconnect:
                  log.info("Sender detached. Attempting reconnect.")
                  self.reconnect()
              else:
                  log.info("Sender detached. Shutting down.")
                  error = EventHubError(str(shutdown), shutdown)
                  self.close(exception=error)
                  raise error
          except Exception as e:
              log.info("Unexpected error occurred (%r).", e)
              raise EventHubError("Send failed: {}".format(e))
docs: Wait until all transferred events have been sent.