File tree 1 file changed +6
-17
lines changed
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
61
61
62
62
// if the original value was already true, run() is already running
63
63
if original {
64
- throw LambdaRuntimeError ( code: . runtimeCanOnlyBeStartedOnce )
64
+ throw LambdaRuntimeError ( code: . moreThanOneLambdaRuntimeInstance )
65
65
}
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)
79
69
}
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 ( )
83
72
}
84
73
85
74
private func _run( ) async throws {
You can’t perform that action at this time.
0 commit comments