MCPcopy
hub / github.com/git-lfs/git-lfs / shutdownWorkerProcess

Method shutdownWorkerProcess

tq/custom.go:214–236  ·  view source on GitHub ↗

shutdownWorkerProcess terminates gracefully a custom adapter process returns an error if it couldn't shut down gracefully (caller may abortWorkerProcess)

(ctx *customAdapterWorkerContext)

Source from the content-addressed store, hash-verified

212// shutdownWorkerProcess terminates gracefully a custom adapter process
213// returns an error if it couldn't shut down gracefully (caller may abortWorkerProcess)
214func (a *customAdapter) shutdownWorkerProcess(ctx *customAdapterWorkerContext) error {
215 defer ctx.errTracer.Flush()
216
217 a.Trace("xfer: Shutting down adapter worker %d", ctx.workerNum)
218
219 finishChan := make(chan error, 1)
220 go func() {
221 termReq := NewCustomAdapterTerminateRequest()
222 err := a.sendMessage(ctx, termReq)
223 if err != nil {
224 finishChan <- err
225 }
226 ctx.stdin.Close()
227 ctx.stdout.Close()
228 finishChan <- ctx.cmd.Wait()
229 }()
230 select {
231 case err := <-finishChan:
232 return err
233 case <-time.After(30 * time.Second):
234 return errors.New(tr.Tr.Get("timeout while shutting down worker process %d", ctx.workerNum))
235 }
236}
237
238// abortWorkerProcess terminates & aborts untidily, most probably breakdown of comms or internal error
239func (a *customAdapter) abortWorkerProcess(ctx *customAdapterWorkerContext) {

Callers 1

WorkerEndingMethod · 0.95

Calls 8

sendMessageMethod · 0.95
NewFunction · 0.92
CloseMethod · 0.65
WaitMethod · 0.65
GetMethod · 0.65
FlushMethod · 0.45
TraceMethod · 0.45

Tested by

no test coverage detected