We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent df4a8c9 commit a43a654Copy full SHA for a43a654
run.go
@@ -135,7 +135,10 @@ func (r *Run) Close() error {
135
return fmt.Errorf("run not started")
136
}
137
138
- r.cancel(errAbortRun)
+ if !r.lock.TryLock() {
139
+ // If we can't get the lock, then the run is still running. Abort it.
140
+ r.cancel(errAbortRun)
141
+ }
142
if r.wait == nil {
143
return nil
144
@@ -285,10 +288,10 @@ func (r *Run) request(ctx context.Context, payload any) (err error) {
285
288
)
286
289
defer func() {
287
290
resp.Body.Close()
- close(r.events)
291
cancel(r.err)
292
r.wait()
293
r.lock.Unlock()
294
+ close(r.events)
295
}()
296
297
r.callsLock.Lock()
0 commit comments