code: def stop_threadsafe(self):
          
  
          if self.stopped:
              return
  
          try:
              self._loop.run_coroutine(self.stop())
          except asyncio.TimeoutError:
              raise TimeoutExpiredError("Timeout stopping task {} with {} subtasks".format(self.name, len(self.subtasks)))
docs: Stop this task from another thread and wait for it to finish.
  
          This method must not be called from within the BackgroundEventLoop but
          will inject self.stop() into the event loop and block until it
          returns.
  
          Raises:
              TimeoutExpiredError: If the task does not stop in the given
                  timeout specified in __init__()