summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.go27
1 files changed, 19 insertions, 8 deletions
diff --git a/main.go b/main.go
index 52db403..b7b84f2 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ import (
"path"
"path/filepath"
"strings"
+ "time"
)
const (
@@ -165,14 +166,9 @@ func main() {
// filteredUtterances := []*Utterance{}
// === concurrent ===
- queue := make(chan *Utterance, 1000)
+ queue := make(chan *Utterance)
done := make(chan bool, 1)
- workers := 10
- for i := 0; i < workers; i++ {
- go worker(queue, i, done)
- }
-
for _, ut := range utterances {
if _, err := os.Stat(ut.OutPath); os.IsNotExist(err) {
queue <- ut
@@ -181,8 +177,23 @@ func main() {
// }
}
}
- done <- true
- close(done)
+
+ fmt.Println("filled queue, starting workers")
+
+ workers := 10
+ for i := 0; i < workers; i++ {
+ go worker(queue, i, done)
+ }
+
+ for {
+ if len(queue) == 0 {
+ done <- true
+ close(done)
+ close(queue)
+ break
+ }
+ time.Sleep(1 * time.Second)
+ }
newMeta := utterancesToFileTextMap(utterances)
writeCSV(mapToCSV(newMeta))
}