diff --git a/pyobs/background_task.py b/pyobs/background_task.py index 6bcc23a6..0ae82f11 100644 --- a/pyobs/background_task.py +++ b/pyobs/background_task.py @@ -2,7 +2,7 @@ import logging from typing import Optional, Coroutine, Any, Callable -from pyobs.utils.exceptions import PyObsError +from pyobs.utils.exceptions import SevereError log = logging.getLogger(__name__) @@ -23,7 +23,7 @@ def _callback_function(self, args=None) -> None: except asyncio.CancelledError: return - if isinstance(exception, PyObsError): + if isinstance(exception, SevereError): raise exception elif exception is not None: log.error("Exception %s in task %s.", exception, self._func.__name__) diff --git a/tests/test_background_task.py b/tests/test_background_task.py index 8c4f6d03..f218a762 100644 --- a/tests/test_background_task.py +++ b/tests/test_background_task.py @@ -46,12 +46,12 @@ async def test_callback_pyobs_error(): test_function.__name__ = "test_function" task = asyncio.create_task(test_function()) - task.exception = Mock(return_value=exc.ImageError("TestError")) + task.exception = Mock(return_value=exc.SevereError(exc.ImageError("TestError"))) bg_task = BackgroundTask(test_function, False) bg_task._task = task - with pytest.raises(exc.ImageError): + with pytest.raises(exc.SevereError): bg_task._callback_function()