diff --git a/runtimepy/task/basic/__init__.py b/runtimepy/task/basic/__init__.py index cf5aefaa..27182ccd 100644 --- a/runtimepy/task/basic/__init__.py +++ b/runtimepy/task/basic/__init__.py @@ -8,6 +8,7 @@ from abc import ABC as _ABC from abc import abstractmethod as _abstractmethod import asyncio as _asyncio +from contextlib import suppress as _suppress from logging import getLogger as _getLogger from typing import Optional as _Optional @@ -72,7 +73,8 @@ async def task(self, period_s: float) -> _asyncio.Task[None]: if self._task is not None: if not self._task.done(): self._task.cancel() - await self._task + with _suppress(_asyncio.CancelledError): + await self._task _log_task_exception(self._task, logger=self.logger) self._task = None