<commit_before>package main

import (
	"fmt"
	"time"
	"sync"
)

func worker(id int, jobs <-chan int, results chan<- int) {
	for j := range jobs {
		fmt.Println("worker", id, "processing job", j)
		time.Sleep(time.Second)
		results <- j * 2
	}
}

func printer(results <-chan int) {

	for r := range results {
		fmt.Println(r)
	}
	
}

func main() {
	jobs := make(chan int, 100)
	results := make(chan int, 100)
	var wg sync.WaitGroup
	// This starts up 3 workers, initially blocked
	// because there are no jobs yet.
	for w := 1; w <= 3; w++ {
		wg.Add(1)
		go worker(w, jobs, results)
	}

	go printer(results)
	// Here we send 9 `jobs` and then `close` that
	// channel to indicate that's all the work we have.
	for j := 1; j <= 9; j++ {
		jobs <- j
	}
	wg.Wait()
	close(jobs)
}<commit_msg>Remove fatal error in workers<commit_after>package main

import (
	"fmt"
	"time"
	"sync"
)

var wg sync.WaitGroup

func worker(id int, jobs <-chan int, results chan<- int) {
	for j := range jobs {
		if j == -1 {
			wg.Done()
			return
		}
		fmt.Println("worker", id, "processing job", j)
		time.Sleep(time.Second)
		results <- j * 2
	}
}

func printer(results <-chan int) {

	for r := range results {
		fmt.Println(r)
	}
}

func main() {
	jobs := make(chan int, 100)
	results := make(chan int, 100)
	// This starts up 3 workers, initially blocked
	// because there are no jobs yet.
	for w := 1; w <= 3; w++ {
		wg.Add(1)
		go worker(w, jobs, results)
	}

	go printer(results)
	// Here we send 9 `jobs` and then `close` that
	// channel to indicate that's all the work we have.
	for j := 1; j <= 9; j++ {
		jobs <- j
	}
	for w := 1; w <= 3; w++ {
		jobs <- -1
	}
	wg.Wait()
}
{'fraction_non_alphanumeric': 0.1582430806257521, 'fraction_numerical': 0.019253910950661854, 'mean_word_length': 2.7968036529680367, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5343813', 'n_tokens_mistral': 721, 'n_tokens_neox': 635, 'n_words': 224}