code: def cancel_pending_tasks(self):
          
          for task in self._pending_tasks:
              task.cancel()
              if not self._loop.is_running():
                  try:
                      self._loop.run_until_complete(task)
                  except asyncio.CancelledError:
                      pass
                  except Exception: # pylint: disable=broad-except
                      _LOGGER.error("Unhandled exception from async task",
                                    exc_info=True)
docs: Cancel all pending tasks.