Skip to content

Commit

Permalink
feat: suppress CancelledError from async runner
Browse files Browse the repository at this point in the history
  • Loading branch information
thegamecracks committed Jun 18, 2024
1 parent 7aa9bd1 commit 6b7db00
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sardine_core/scheduler/async_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def start(self):
return

self._task = asyncio.create_task(self._runner())
self._task.add_done_callback(asyncio.Task.result)
self._task.add_done_callback(self._on_task_done)

def is_running(self) -> bool:
"""Returns True if the runner is running."""
Expand Down Expand Up @@ -867,3 +867,9 @@ def _skip_iteration(self) -> None:
def _jump_start_iteration(self) -> None:
self._jump_start = True
self._skip_iteration()

def _on_task_done(self, task: asyncio.Task) -> None:
if task.cancelled():
return # Suppress CancelledError

task.result() # Raise any exception if present

0 comments on commit 6b7db00

Please sign in to comment.