fix concurrency api usage (#282)

motivation: cleanup incorrect concurent code in test

changes: use .get instead of .wait
This commit is contained in:
tomer doron
2023-01-10 16:24:11 -08:00
committed by GitHub
parent dc64ce195b
commit a5fb165f65
3 changed files with 9 additions and 6 deletions
@@ -158,3 +158,6 @@ extension Result {
}
}
}
/// This is safe since lambda runtime synchronizes by dispatching all methods to a single `EventLoop`
extension LambdaRunner: @unchecked Sendable {}
@@ -266,7 +266,7 @@ class LambdaTest: XCTestCase {
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
let server = try MockLambdaServer(behavior: Behavior()).start().wait()
let server = try await MockLambdaServer(behavior: Behavior()).start().get()
defer { XCTAssertNoThrow(try server.stop().wait()) }
let logger = Logger(label: "TestLogger")
@@ -278,17 +278,17 @@ class LambdaTest: XCTestCase {
logger.info("hello")
let runner = LambdaRunner(eventLoop: eventLoopGroup.next(), configuration: configuration)
try runner.run(
try await runner.run(
handler: CodableEventLoopLambdaHandler(
handler: handler1,
allocator: ByteBufferAllocator()
),
logger: logger
).wait()
).get()
try runner.initialize(handlerType: CodableEventLoopLambdaHandler<Handler>.self, logger: logger, terminator: LambdaTerminator()).flatMap { handler2 in
try await runner.initialize(handlerType: CodableEventLoopLambdaHandler<Handler>.self, logger: logger, terminator: LambdaTerminator()).flatMap { handler2 in
runner.run(handler: handler2, logger: logger)
}.wait()
}.get()
}
try await task.value
+1 -1
View File
@@ -1,6 +1,6 @@
# this file is not designed to be run directly
# instead, use the docker-compose.<os>.<swift> files
# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.al2.55.yaml run test
# eg docker-compose -f docker/docker-compose.yaml -f docker/docker-compose.al2.57.yaml run test
version: "3"
services: