code: def stream_events(signals: Sequence[Signal], filter: Callable[[T_Event], bool] = None, *,
                    max_queue_size: int = 0) -> AsyncIterator[T_Event]:
      
      @async_generator
      async def streamer():
          try:
              while True:
                  event = await queue.get()
                  if filter is None or filter(event):
                      await yield_(event)
          finally:
              cleanup()
  
      def cleanup():
          nonlocal queue
          if queue is not None:
              for signal in signals:
                  signal.disconnect(queue.put_nowait)
  
              queue = None
  
      assert check_argument_types()
      queue = Queue(max_queue_size)  # type: Queue[T_Event]
      for signal in signals:
          signal.connect(queue.put_nowait)
  
      gen = [streamer()]  # this is to allow the reference count to drop to 0
      weakref.finalize(gen[0], cleanup)
      return gen.pop()
docs: Return an async generator that yields events from the given signals.
  
      Only events that pass the filter callable (if one has been given) are returned.
      If no filter function was given, all events are yielded from the generator.
  
      :param signals: the signals to get events from
      :param filter: a callable that takes an event object as an argument and returns ``True`` if
          the event should pass, ``False`` if not
      :param max_queue_size: maximum size of the queue, after which it will start to drop events