From 1a32550e9f2bfc9c7a2d8e91f9e5c04dc1502122 Mon Sep 17 00:00:00 2001 From: nocturn9x Date: Thu, 13 Jun 2024 01:46:13 +0200 Subject: [PATCH] Fix scope cancellation bug --- structio/core/kernel.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/structio/core/kernel.py b/structio/core/kernel.py index 2a18faf..4d62bbf 100644 --- a/structio/core/kernel.py +++ b/structio/core/kernel.py @@ -540,13 +540,15 @@ class DefaultKernel(Kernel): # so there is nowhere to throw an exception # to: instead, we delay the cancellation until # the next tick - if self.current_task in scope.tasks: - self.current_task.pending_cancellation = True - self.reschedule(self.current_task) + self.current_task.pending_cancellation = True + self.reschedule(self.current_task) else: self.cancel_task(task) if scope.done(): scope.cancelled = True + # All inner tasks cancelled: reschedule + # scope owner so it can keep going + self.reschedule(scope.owner) def init_pool(self, pool: TaskPool): pool.outer = self.current_pool