Skip to content

Commit 078c77f

Browse files
Correct a spurious slot release (#220)
The slot release was incorrect and was run outside of the manager.predict function meaning we effectively had more slots than expected. This change eliminates the added .releaseSlot() call in the wrong method.
1 parent 5d32bf9 commit 078c77f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/runner/manager.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,20 @@ func (m *Manager) Start(ctx context.Context) error {
136136
func (m *Manager) claimSlot() error {
137137
select {
138138
case <-m.capacity:
139+
m.logger.Trace("claiming slot")
139140
return nil
140141
default:
142+
m.logger.Trace("attempted claim slot but no slot available")
141143
return ErrNoCapacity
142144
}
143145
}
144146

145147
func (m *Manager) releaseSlot() {
146148
select {
147149
case m.capacity <- struct{}{}:
150+
m.logger.Trace("releasing slot")
148151
default:
149-
m.logger.Warn("attempted to release slot but channel is full")
152+
m.logger.Error("attempted to release slot but channel is full")
150153
}
151154
}
152155

@@ -172,8 +175,7 @@ func (m *Manager) PredictAsync(ctx context.Context, req PredictionRequest) (*Pre
172175

173176
// Release slot when prediction completes in background
174177
go func() {
175-
defer m.releaseSlot() // Release slot after prediction completes
176-
<-respChan // Wait for prediction to complete
178+
<-respChan // Wait for prediction to complete
177179
log.Tracew("async prediction completed", "prediction_id", req.ID)
178180
}()
179181

0 commit comments

Comments
 (0)