docs: async def stream(self,
                       event_type: Type[TStreamEvent],
                       num_events: Optional[int] = None) -> AsyncGenerator[TStreamEvent, None]:
          """
          Stream all events that match the specified event type. This returns an
          ``AsyncIterable[BaseEvent]`` which can be consumed through an ``async for`` loop.
          An optional ``num_events`` parameter can be passed to stop streaming after a maximum amount
          of events was received.
          """
          queue: asyncio.Queue = asyncio.Queue()
  
          if event_type not in self._queues:
              self._queues[event_type] = []
  
          self._queues[event_type].append(queue)
          i = None if num_events is None else 0
          while True:
              try:
                  yield await queue.get()
              except GeneratorExit:
                  self._queues[event_type].remove(queue)
                  break
              except asyncio.CancelledError:
                  self._queues[event_type].remove(queue)
                  break
              else:
                  if i is None:
                      continue
  
                  i += 1
  
                  if i >= cast(int, num_events):
                      self._queues[event_type].remove(queue)
                      break