Fix scope cancellation bug

This commit is contained in:
Mattia Giambirtone 2024-06-13 01:46:13 +02:00
parent c4e07a0da1
commit 1a32550e9f
1 changed files with 5 additions and 3 deletions

View File

@ -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