From 5e705a2f647bbcf2b95006e7516c64f5f50fd47f Mon Sep 17 00:00:00 2001 From: qstokkink Date: Mon, 25 Nov 2024 10:40:10 +0100 Subject: [PATCH] DEBUG/DROPME: Mac, what doing? --- ipv8/taskmanager.py | 16 ++++++++++++---- ipv8/test/test_taskmanager.py | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ipv8/taskmanager.py b/ipv8/taskmanager.py index 01b8d6568..c07e61b8a 100644 --- a/ipv8/taskmanager.py +++ b/ipv8/taskmanager.py @@ -252,11 +252,19 @@ async def after_cancel() -> None: await cast(Awaitable, fut) done_future.after_cancel_task = after_cancel() # type: ignore[attr-defined] - self.register_anonymous_task(f"[Catch shutdown] {basename}", catch_shutdown) - self.register_anonymous_task(f"[Run shutdown] {basename}", - shield(done_future.after_cancel_task)) # type: ignore[attr-defined] + t1 = self.register_anonymous_task(f"[Catch shutdown] {basename}", catch_shutdown) + t2 = self.register_anonymous_task(f"[Run shutdown] {basename}", + shield(done_future.after_cancel_task)) # type: ignore[attr-defined] + + while t1._callbacks is None or len(t1._callbacks) == 0: + await sleep(0) # Enter both infinite loops + + while t2._callbacks is None or len(t2._callbacks) < 2: + await sleep(0) # Enter both infinite loops + + while done_future._callbacks is None or len(done_future._callbacks) == 0: + await sleep(0) # Enter both infinite loops - await sleep(0) # Enter both infinite loops return done_future diff --git a/ipv8/test/test_taskmanager.py b/ipv8/test/test_taskmanager.py index 98c4e982f..eddd6e0e9 100644 --- a/ipv8/test/test_taskmanager.py +++ b/ipv8/test/test_taskmanager.py @@ -301,6 +301,8 @@ async def test_register_shutdown_task(self) -> None: await self.tm.shutdown_task_manager() + print(fut) # TODO: Mac, what are you doing!? + self.assertTrue(fut.done()) self.assertTrue(sub_fut.cancelled())