From 0560298f0f6c8c7f0a0f207626a1845f9e49fa7d Mon Sep 17 00:00:00 2001 From: Nocturn9x Date: Wed, 22 Feb 2023 14:04:53 +0100 Subject: [PATCH] Fixed cancellation mechanism --- aiosched/internals/syscalls.py | 2 +- aiosched/kernel.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/aiosched/internals/syscalls.py b/aiosched/internals/syscalls.py index e6024e6..28c8dd5 100644 --- a/aiosched/internals/syscalls.py +++ b/aiosched/internals/syscalls.py @@ -184,7 +184,7 @@ async def cancel(task: Task, block: bool = False): :type block: bool, optional """ - await syscall("cancel", task) + await syscall("cancel", task, block) if block: await wait(task) if not task.state == TaskState.CANCELLED: diff --git a/aiosched/kernel.py b/aiosched/kernel.py index 4a5b640..d0f7deb 100644 --- a/aiosched/kernel.py +++ b/aiosched/kernel.py @@ -422,7 +422,7 @@ class FIFOKernel: self.handle_errors(partial(k.data.throw, exc), k.data) self.reschedule_running() - def cancel(self, task: Task): + def cancel(self, task: Task, block: bool = True): """ Attempts to cancel the given task or schedules cancellation for later if @@ -434,7 +434,8 @@ class FIFOKernel: task.pending_cancellation = True self.io_release_task(task) self.paused.discard(task) - self.reschedule_running() + if not block: + self.reschedule_running() def handle_errors(self, func: Callable, task: Task | None = None): """