Fixed cancellation mechanism

This commit is contained in:
Nocturn9x 2023-02-22 14:04:53 +01:00
parent 4e41e46975
commit 0560298f0f
2 changed files with 4 additions and 3 deletions

View File

@ -184,7 +184,7 @@ async def cancel(task: Task, block: bool = False):
:type block: bool, optional :type block: bool, optional
""" """
await syscall("cancel", task) await syscall("cancel", task, block)
if block: if block:
await wait(task) await wait(task)
if not task.state == TaskState.CANCELLED: if not task.state == TaskState.CANCELLED:

View File

@ -422,7 +422,7 @@ class FIFOKernel:
self.handle_errors(partial(k.data.throw, exc), k.data) self.handle_errors(partial(k.data.throw, exc), k.data)
self.reschedule_running() self.reschedule_running()
def cancel(self, task: Task): def cancel(self, task: Task, block: bool = True):
""" """
Attempts to cancel the given task or Attempts to cancel the given task or
schedules cancellation for later if schedules cancellation for later if
@ -434,7 +434,8 @@ class FIFOKernel:
task.pending_cancellation = True task.pending_cancellation = True
self.io_release_task(task) self.io_release_task(task)
self.paused.discard(task) self.paused.discard(task)
self.reschedule_running() if not block:
self.reschedule_running()
def handle_errors(self, func: Callable, task: Task | None = None): def handle_errors(self, func: Callable, task: Task | None = None):
""" """