Skip to content

Commit

Permalink
DEBUG/DROPME: Mac, what doing?
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Nov 25, 2024
1 parent 3ce7030 commit 2c363bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 16 additions & 4 deletions ipv8/taskmanager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import asyncio
import logging
import time
import traceback
Expand Down Expand Up @@ -251,13 +252,24 @@ async def after_cancel() -> None:
if not callable(task) or iscoroutinefunction(task):
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)
inner_t2 = ensure_future(after_cancel())
t2 = self.register_anonymous_task(f"[Run shutdown] {basename}", shield(inner_t2))

print()
print(t1)
print(inner_t2)
print(t2)
print(done_future)

await sleep(0) # Enter both infinite loops

print(t1)
print(inner_t2)
print(t2)
print(done_future)


return done_future

def cancel_pending_task(self, name: Hashable) -> Future:
Expand Down
2 changes: 2 additions & 0 deletions ipv8/test/test_taskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand Down

0 comments on commit 2c363bf

Please sign in to comment.