From d0ada54ce16f9c0ee91046de5668f0e339c84ff9 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 24 Dec 2024 09:19:41 +0000 Subject: [PATCH] move assert --- src/trio/_core/_run.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/trio/_core/_run.py b/src/trio/_core/_run.py index 1dba56b02..c364aa81d 100644 --- a/src/trio/_core/_run.py +++ b/src/trio/_core/_run.py @@ -2104,14 +2104,14 @@ def deliver_ki(self) -> None: def _deliver_ki_cb(self) -> None: if not self.ki_pending: return - # Can't happen because main_task and run_sync_soon_task are created at - # the same time -- so even if KI arrives before main_task is created, - # we won't get here until afterwards. - assert self.main_task is not None if self.main_task_outcome is not None: # We're already in the process of exiting -- leave ki_pending set # and we'll check it again on our way out of run(). return + # Can't happen because main_task and run_sync_soon_task are created at + # the same time -- so even if KI arrives before main_task is created, + # we won't get here until afterwards. + assert self.main_task is not None self.main_task._attempt_delivery_of_pending_ki() ################