Maint: context aware collectLines functions

This commit is contained in:
Quentin McGaw (desktop)
2021-08-16 19:19:33 +00:00
parent 2c73672e64
commit ba16270059
4 changed files with 36 additions and 22 deletions

View File

@@ -80,11 +80,12 @@ func (l *Loop) Run(ctx context.Context, done chan<- struct{}) {
continue
}
linesCollectionCtx, linesCollectionCancel := context.WithCancel(context.Background())
lineCollectionDone := make(chan struct{})
go l.collectLines(stdoutLines, stderrLines, lineCollectionDone)
go l.collectLines(linesCollectionCtx, lineCollectionDone,
stdoutLines, stderrLines)
closeStreams := func() {
close(stdoutLines)
close(stderrLines)
linesCollectionCancel()
<-lineCollectionDone
}