Skip to content

cancelOnGracefulShutdown never returns #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sliemeobn opened this issue May 7, 2023 · 0 comments
Closed

cancelOnGracefulShutdown never returns #135

sliemeobn opened this issue May 7, 2023 · 0 comments

Comments

@sliemeobn
Copy link
Contributor

sliemeobn commented May 7, 2023

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.

sliemeobn added a commit to sliemeobn/swift-service-lifecycle that referenced this issue May 7, 2023
Motivation:
+ cancelOnGracefulShutdown was getting stuck on macOS

Modifications:
+ added explicit group.cancelAll() to all execution paths
sliemeobn added a commit to sliemeobn/swift-service-lifecycle that referenced this issue May 7, 2023
Motivation:
+ cancelOnGracefulShutdown was getting stuck on macOS

Modifications:
+ added explicit group.cancelAll() to all execution paths
FranzBusch pushed a commit that referenced this issue May 11, 2023
Motivation:
+ cancelOnGracefulShutdown was getting stuck on macOS

Modifications:
+ added explicit group.cancelAll() to all execution paths

Co-authored-by: Simon Leeb <[email protected]>
@sliemeobn sliemeobn changed the title cancelOnGracefulShutdown never returns (macOS, Swift 5.8) cancelOnGracefulShutdown never returns May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants