(self)
Captures incoming messages until stop time or signal received.
Captures incoming messages until stop time or signal received.
Captures incoming messages until stop time or signal received .
def run(self):
    """Captures incoming messages until stop time or signal received."""
    while True:
      timeout = None
      stop_time = self._stop_time
      if stop_time is not None:
        timeout = stop_time - time.time()
        if timeout <= 0:
          break
      try:
        msg = self._receive_queue.get(block=True, timeout=timeout)
      except queue.Empty:
        continue

      if msg is MidiCaptor._WAKE_MESSAGE:
        continue

      if msg.time <= self._start_time:
        continue

      if self._stop_regex.match(str(msg)) is not None:
        break

      with self._lock:
        msg_str = str(msg)
        for regex, queue_ in self._iter_signals:
          if regex.match(msg_str) is not None:
            queue_.put(msg.copy())

      self._capture_message(msg)

    stop_time = self._stop_time
    end_time = stop_time if stop_time is not None else msg.time

    # Acquire lock to avoid race condition with `iterate`.
    with self._lock:
      # Set final captured sequence.
      self._captured_sequence = self.captured_sequence(end_time)
      # Wake up all generators.
      for regex, queue_ in self._iter_signals:
        queue_.put(MidiCaptor._WAKE_MESSAGE)
def run ( self ) : while True : timeout = None stop_time = self . _stop_time if stop_time is not None : timeout = stop_time - time . time ( ) if timeout <= 0 : break try : msg = self . _receive_queue . get ( block = True , timeout = timeout ) except queue . Empty : continue if msg is MidiCaptor . _WAKE_MESSAGE : continue if msg . time <= self . _start_time : continue if self . _stop_regex . match ( str ( msg ) ) is not None : break with self . _lock : msg_str = str ( msg ) for regex , queue_ in self . _iter_signals : if regex . match ( msg_str ) is not None : queue_ . put ( msg . copy ( ) ) self . _capture_message ( msg ) stop_time = self . _stop_time end_time = stop_time if stop_time is not None else msg . time # Acquire lock to avoid race condition with `iterate`. with self . _lock : # Set final captured sequence. self . _captured_sequence = self . captured_sequence ( end_time ) # Wake up all generators. for regex , queue_ in self . _iter_signals : queue_ . put ( MidiCaptor . _WAKE_MESSAGE )