Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging interference with worker and main thread #174

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion project.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ func (project Project) WalkTodosOfDir(dirpath string) (<-chan TodoResult, contex
output := make(chan TodoResult)
var workers sync.WaitGroup

print := make(chan string)
go func() {
for {
select {
case <-ctx.Done():
close(print)
return
case v := <-print:
defer fmt.Println(v)
}
}
}()

for i := 0; i < runtime.NumCPU(); i++ {
workers.Add(1)
go func() {
Expand All @@ -219,7 +232,7 @@ func (project Project) WalkTodosOfDir(dirpath string) (<-chan TodoResult, contex
}
if stat.IsDir() {
// FIXME(#145): snitch should go inside of git submodules recursively
fmt.Printf("[WARN] `%s` is probably a submodule. Skipping it for now...\n", filepath)
print <- fmt.Sprintf("[WARN] `%s` is probably a submodule. Skipping it for now...", filepath)
continue
}

Expand Down