File tree Expand file tree Collapse file tree 1 file changed +6
-17
lines changed Expand file tree Collapse file tree 1 file changed +6
-17
lines changed Original file line number Diff line number Diff line change @@ -61,25 +61,14 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
6161
6262 // if the original value was already true, run() is already running
6363 if original {
64- throw LambdaRuntimeError ( code: . runtimeCanOnlyBeStartedOnce )
64+ throw LambdaRuntimeError ( code: . moreThanOneLambdaRuntimeInstance )
6565 }
66-
67- try await withTaskCancellationHandler {
68- // call the internal _run() method
69- do {
70- try await self . _run ( )
71- } catch {
72- // when we catch an error, flip back the global variable to false
73- _isRunning. store ( false , ordering: . relaxed)
74- throw error
75- }
76- } onCancel: {
77- // when task is cancelled, flip back the global variable to false
78- _isRunning. store ( false , ordering: . relaxed)
66+
67+ defer {
68+ _isRunning. store ( false , ordering: . releasing)
7969 }
80-
81- // when we're done without error and without cancellation, flip back the global variable to false
82- _isRunning. store ( false , ordering: . relaxed)
70+
71+ try await self . _run ( )
8372 }
8473
8574 private func _run( ) async throws {
You can’t perform that action at this time.
0 commit comments