code: def wait_stop(self):
          
          if not self.running:
              return
          self.stop()
          try:
              yield from self._task
          except asyncio.CancelledError:
              pass
docs: Stop the stream and wait for it to stop.
  
          See :meth:`stop` for the general stopping conditions. You can assume
          that :meth:`stop` is the first thing this coroutine calls.