diff --git a/aiosched/internals/syscalls.py b/aiosched/internals/syscalls.py index 28c8dd5..ee08e2f 100644 --- a/aiosched/internals/syscalls.py +++ b/aiosched/internals/syscalls.py @@ -157,11 +157,11 @@ async def wait(task: Task) -> Any | None: raise SchedulerError("a task cannot join itself") if current not in task.joiners: # Luckily we use a set, so this has O(1) - # complexity + # complexity on average await join(task) # Waiting implies joining! await syscall("wait", task) if task.exc and task.state != TaskState.CANCELLED and task.propagate: - # Task raised an error that wasn't directly caused by a cancellation: + # The task raised an error that wasn't directly caused by a cancellation: # raise it, but do so only the first time wait was called task.propagate = False raise task.exc @@ -184,7 +184,7 @@ async def cancel(task: Task, block: bool = False): :type block: bool, optional """ - await syscall("cancel", task, block) + await syscall("cancel", task) if block: await wait(task) if not task.state == TaskState.CANCELLED: diff --git a/aiosched/kernel.py b/aiosched/kernel.py index d0f7deb..1047e92 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, block: bool = True): + def cancel(self, task: Task): """ Attempts to cancel the given task or schedules cancellation for later if @@ -434,8 +434,7 @@ class FIFOKernel: task.pending_cancellation = True self.io_release_task(task) self.paused.discard(task) - if not block: - self.reschedule_running() + self.reschedule_running() def handle_errors(self, func: Callable, task: Task | None = None): """ @@ -510,8 +509,6 @@ class FIFOKernel: self.paused.discard(task) self.io_release_task(task) self.run_ready.extend(task.joiners) - if task is not self.current_task: - self.reschedule_running() def join(self, task: Task): """