Skip to content

Commit 27a2534

Browse files
shutdown client when done
1 parent 098201c commit 27a2534

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Sources/SwiftlyCore/HTTPClient.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ public final class HTTPRequestExecutorImpl: HTTPRequestExecutor {
152152
}
153153
}
154154

155+
public func shutdown() async throws {
156+
if httpClient !== HTTPClient.shared {
157+
try await httpClient.shutdown()
158+
}
159+
}
160+
155161
private func websiteClient() throws -> SwiftlyWebsiteAPI.Client {
156162
let swiftlyUserAgent = SwiftlyUserAgentMiddleware()
157163
let transport: ClientTransport

Tools/build-swiftly-release/BuildSwiftlyRelease.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import AsyncHTTPClient
33
import Foundation
44
import SwiftlyCore
55
import SystemPackage
6-
import NIOPosix
76

87
#if os(macOS)
98
import MacOSPlatform
@@ -152,6 +151,12 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
152151

153152
// Download libarchive
154153
let httpExecutor = HTTPRequestExecutorImpl()
154+
defer {
155+
Task {
156+
try? await httpExecutor.shutdown()
157+
}
158+
}
159+
155160
let libarchiveRequest = HTTPClientRequest(url: "https://github.com/libarchive/libarchive/releases/download/v\(libArchiveVersion)/libarchive-\(libArchiveVersion).tar.gz")
156161
let libarchiveResponse = try await httpExecutor.httpClient.execute(libarchiveRequest, timeout: .seconds(60))
157162
guard libarchiveResponse.status == .ok else {
@@ -182,7 +187,6 @@ struct BuildSwiftlyRelease: AsyncParsableCommand {
182187
}
183188

184189
let swiftVersion = swiftVerMatch.output.1
185-
print("Get toolchains")
186190
guard let swiftRelease = (try await httpExecutor.getReleaseToolchains()).first(where: { $0.name == swiftVersion }) else {
187191
throw Error(message: "Unable to find swift release using swift.org API: \(swiftVersion)")
188192
}

0 commit comments

Comments
 (0)