cancelOnGracefulShutdown never returns
sliemeobn opened this issue · 0 comments
sliemeobn commented
In version 2.0.0-alpha.1
swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0
Calling cancelOnGracefulShutdown
currently never finishes, because the withThrowingTaskGroup
keeps running the "waiting-for-graceful-shutdown" task.
Afaik this is due to some unfortunate inconsistency with task groups with their "cancelAll on return" behavior.
edit: this has nothing to do with environment or inconsistencies, was just a plain bug.
This test will never finish in my environment:
func testResumesCancelOnGracefulShutdownWithResult() async throws {
await testGracefulShutdown { _ in
let result = await cancelOnGracefulShutdown {
await Task.yield()
return "hello"
}
XCTAssertEqual(result, "hello")
}
}
Adding a "manual" group.cancelAll()
should do the trick.