<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cancel_pending_tasks(self):
 """Cancel all pending tasks."""

        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)