original_docstring: 
          Wait for a set of patterns to match or until timeout is reached.
  
          :param ~collections.abc.Sequence pattern:
              An iterable of tuples in the form of ``("<daemon-id>", "<event-tag-pattern>")``, ie, which daemon ID
              we're targeting and the event tag pattern which will be passed to :py:func:`~fnmatch.fnmatch` to
              assert a match.
          :keyword int,float timeout:
              The amount of time to wait for the events, in seconds.
          :keyword ~datetime.datetime,float after_time:
              After which time to start matching events.
  
          :return:
              An instance of :py:class:`~saltfactories.plugins.event_listener.MatchedEvents`.
          :rtype ~saltfactories.plugins.event_listener.MatchedEvents:
          
docstring: Wait for a set of patterns to match or until timeout is reached.
docstring_tokens: Wait for a set of patterns to match or until timeout is reached .
code: def wait_for_events(self, patterns, timeout=30, after_time=None):
          """
          Wait for a set of patterns to match or until timeout is reached.
  
          :param ~collections.abc.Sequence pattern:
              An iterable of tuples in the form of ``("<daemon-id>", "<event-tag-pattern>")``, ie, which daemon ID
              we're targeting and the event tag pattern which will be passed to :py:func:`~fnmatch.fnmatch` to
              assert a match.
          :keyword int,float timeout:
              The amount of time to wait for the events, in seconds.
          :keyword ~datetime.datetime,float after_time:
              After which time to start matching events.
  
          :return:
              An instance of :py:class:`~saltfactories.plugins.event_listener.MatchedEvents`.
          :rtype ~saltfactories.plugins.event_listener.MatchedEvents:
          """
          if after_time is None:
              after_time = datetime.utcnow()
          elif isinstance(after_time, float):
              after_time = datetime.utcfromtimestamp(after_time)
          after_time_iso = after_time.isoformat()
          log.debug(
              "%s is waiting for event patterns happening after %s: %s",
              self,
              after_time_iso,
              set(patterns),
          )
          found_events = set()
          patterns = set(patterns)
          timeout_at = time.time() + timeout
          while True:
              if not patterns:
                  return True
              for event in copy.copy(self.store):
                  if event.expired:
                      # Too old, carry on
                      continue
                  if event.stamp < after_time:
                      continue
                  for pattern in set(patterns):
                      _daemon_id, _pattern = pattern
                      if event.daemon_id != _daemon_id:
                          continue
                      if fnmatch.fnmatch(event.tag, _pattern):
                          log.debug("%s Found matching pattern: %s", self, pattern)
                          found_events.add(event)
                          patterns.remove((event.daemon_id, _pattern))
              if not patterns:
                  break
              if time.time() > timeout_at:
                  break
              time.sleep(0.5)
          return MatchedEvents(matches=found_events, missed=patterns)
code_tokens: def wait_for_events ( self , patterns , timeout = 30 , after_time = None ) : if after_time is None : after_time = datetime . utcnow ( ) elif isinstance ( after_time , float ) : after_time = datetime . utcfromtimestamp ( after_time ) after_time_iso = after_time . isoformat ( ) log . debug ( "%s is waiting for event patterns happening after %s: %s" , self , after_time_iso , set ( patterns ) , ) found_events = set ( ) patterns = set ( patterns ) timeout_at = time . time ( ) + timeout while True : if not patterns : return True for event in copy . copy ( self . store ) : if event . expired : continue if event . stamp < after_time : continue for pattern in set ( patterns ) : _daemon_id , _pattern = pattern if event . daemon_id != _daemon_id : continue if fnmatch . fnmatch ( event . tag , _pattern ) : log . debug ( "%s Found matching pattern: %s" , self , pattern ) found_events . add ( event ) patterns . remove ( ( event . daemon_id , _pattern ) ) if not patterns : break if time . time ( ) > timeout_at : break time . sleep ( 0.5 ) return MatchedEvents ( matches = found_events , missed = patterns )
short_docstring: Wait for a set of patterns to match or until timeout is reached.
short_docstring_tokens: Wait for a set of patterns to match or until timeout is reached .
comment: """
          Wait for a set of patterns to match or until timeout is reached.
  
          :param ~collections.abc.Sequence pattern:
              An iterable of tuples in the form of ``("<daemon-id>", "<event-tag-pattern>")``, ie, which daemon ID
              we're targeting and the event tag pattern which will be passed to :py:func:`~fnmatch.fnmatch` to
              assert a match.
          :keyword int,float timeout:
              The amount of time to wait for the events, in seconds.
          :keyword ~datetime.datetime,float after_time:
              After which time to start matching events.
  
          :return:
              An instance of :py:class:`~saltfactories.plugins.event_listener.MatchedEvents`.
          :rtype ~saltfactories.plugins.event_listener.MatchedEvents:
          """$SEP$# Too old, carry on