MCPcopy Index your code
hub / github.com/apache/devlake / createContext

Function createContext

backend/core/runner/directrun.go:117–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

115}
116
117func createContext() context.Context {
118 ctx, cancel := context.WithCancel(context.Background())
119 sigc := make(chan os.Signal, 1)
120 signal.Notify(sigc, getStopSignals()...)
121 go func() {
122 <-sigc
123 cancel()
124 }()
125 go func() {
126 var buf string
127
128 n, err := fmt.Scan(&buf)
129 if err != nil {
130 if goerror.Is(err, io.EOF) {
131 return
132 }
133 panic(err)
134 } else if n == 1 && buf == "c" {
135 cancel()
136 } else {
137 println("unknown key press, code: ", buf)
138 println("press `c` and enter to send cancel signal")
139 }
140 }()
141 println("press `c` and enter to send cancel signal")
142 return ctx
143}
144
145func getStopSignals() []os.Signal {
146 if runtime.GOOS == "windows" {

Callers 2

DirectRunFunction · 0.85
context.tsxFile · 0.85

Calls 2

getStopSignalsFunction · 0.85
ScanMethod · 0.65

Tested by

no test coverage detected