MCPcopy
hub / github.com/mudler/LocalAI / Close

Method Close

core/services/cloudproxy/backend_forward.go:193–208  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191}
192
193func (r *forwardReader) Close() error {
194 // Drain any remaining replies so the server-side goroutine isn't
195 // left blocked. The stream is request-scoped; when the parent
196 // context is cancelled (handler returns), Recv returns and we
197 // exit. A misbehaving backend that keeps emitting replies after
198 // cancellation is bounded by the iteration cap.
199 for i := 0; i < 1024; i++ {
200 if _, err := r.stream.Recv(); err != nil {
201 return nil
202 }
203 if r.stream.Context().Err() != nil {
204 return nil
205 }
206 }
207 return nil
208}

Calls 3

ErrMethod · 0.80
RecvMethod · 0.65
ContextMethod · 0.65