Skip to content

Commit

Permalink
Changed excn filter in background task to severe error
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanHydrogen committed Mar 22, 2024
1 parent e3beb32 commit 0b37f2e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyobs/background_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_background_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down

0 comments on commit 0b37f2e

Please sign in to comment.