From f410433aac82ef655e021b26a020d1741a0a9a30 Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Wed, 20 Aug 2025 19:10:17 +0800 Subject: [PATCH] test context --- Sources/Punchnet/SDLContext.swift | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Sources/Punchnet/SDLContext.swift b/Sources/Punchnet/SDLContext.swift index 66d3bda..9f3540b 100644 --- a/Sources/Punchnet/SDLContext.swift +++ b/Sources/Punchnet/SDLContext.swift @@ -108,6 +108,10 @@ public class SDLContext: @unchecked Sendable { self.rootTask = Task { try await withThrowingTaskGroup(of: Void.self) { group in group.addTask { + defer { + self.logger.log("[SDLContext] UDPHole exit", level: .debug) + } + while !Task.isCancelled { do { try await self.startUDPHole() @@ -119,6 +123,10 @@ public class SDLContext: @unchecked Sendable { } group.addTask { + defer { + self.logger.log("[SDLContext] SuperClient exit", level: .debug) + } + while !Task.isCancelled { do { try await self.startSuperClient() @@ -135,6 +143,10 @@ public class SDLContext: @unchecked Sendable { } group.addTask { + defer { + self.logger.log("[SDLContext] noticeClient exit", level: .debug) + } + while !Task.isCancelled { do { try await self.startNoticeClient() @@ -149,6 +161,11 @@ public class SDLContext: @unchecked Sendable { } } + Task { + try await Task.sleep(for: .seconds(20)) + self.rootTask?.cancel() + } + try await self.rootTask?.value }