MCPcopy
hub / github.com/lmorg/murex / runModeTry

Function runModeTry

lang/interpreter_pc.go:57–102  ·  view source on GitHub ↗

`try` - Last process in each pipe is checked.

(procs *[]Process, tryErr bool)

Source from the content-addressed store, hash-verified

55
56// `try` - Last process in each pipe is checked.
57func runModeTry(procs *[]Process, tryErr bool) (exitNum int) {
58 if len((*procs)) == 0 {
59 return 1
60 }
61
62 for i := 0; i < len(*procs); i++ {
63 go executeProcess(&(*procs)[i])
64 next := i + 1
65
66 if next == len((*procs)) || !(*procs)[next].IsMethod {
67 waitProcess(&(*procs)[i])
68 exitNum = (*procs)[i].ExitNum
69
70 if tryErr {
71 checkTryErr(&(*procs)[i], &exitNum)
72 }
73
74 if next < len(*procs) {
75 if exitNum < 1 && (*procs)[next].OperatorLogicOr {
76 i++
77 (*procs)[i].SetTerminatedState(true)
78 (*procs)[i].Stdout.Close()
79 (*procs)[i].Stderr.Close()
80 GlobalFIDs.Deregister((*procs)[i].Id)
81 (*procs)[i].State.Set(state.AwaitingGC)
82 continue
83 }
84
85 if exitNum > 0 && !(*procs)[next].OperatorLogicOr {
86 for i++; i < len(*procs); i++ {
87 (*procs)[i].Stdout.Close()
88 (*procs)[i].Stderr.Close()
89 GlobalFIDs.Deregister((*procs)[i].Id)
90 (*procs)[i].State.Set(state.AwaitingGC)
91 }
92 return
93 }
94 }
95
96 } else {
97 go waitProcess(&(*procs)[i])
98 }
99 }
100
101 return
102}
103
104// `trypipe` - Each process in the pipeline is tried sequentially. Breaks parallelization.
105func runModeTryPipe(procs *[]Process, tryPipeErr bool) (exitNum int) {

Callers 1

ExecuteMethod · 0.70

Calls 7

executeProcessFunction · 0.85
waitProcessFunction · 0.85
checkTryErrFunction · 0.85
SetTerminatedStateMethod · 0.80
DeregisterMethod · 0.80
CloseMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected