code: def wait(self):
          
          running = True
          while running and self.messages_pending():
              running = self.do_work()
          return running
docs: Run the client until all pending message in the queue
          have been processed. Returns whether the client is still running after the
          messages have been processed, or whether a shutdown has been initiated.
  
          :rtype: bool