code: def _check_pending(self, tag, match_func=None):
          
          if match_func is None:
              match_func = self._get_match_func()
          old_events = self.pending_events
          self.pending_events = []
          ret = None
          for evt in old_events:
              if match_func(evt['tag'], tag):
                  if ret is None:
                      ret = evt
                      log.trace('get_event() returning cached event = %s', ret)
                  else:
                      self.pending_events.append(evt)
              elif any(pmatch_func(evt['tag'], ptag) for ptag, pmatch_func in self.pending_tags):
                  self.pending_events.append(evt)
              else:
                  log.trace('get_event() discarding cached event that no longer has any subscriptions = %s', evt)
          return ret
docs: Check the pending_events list for events that match the tag
  
          :param tag: The tag to search for
          :type tag: str
          :param tags_regex: List of re expressions to search for also
          :type tags_regex: list[re.compile()]
          :return: