<commit_before>package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/codemodus/sigmon"
)

var (
	// slow enables a slowing of the digest function and may help users to
	// better understand the implementation of concurrency
	slow = false

	// width controls the amount of goroutines running the digest function
	width = 8
)

func main() {
	sm := sigmon.New(nil)
	sm.Run()

	// define and parse flags
	flag.BoolVar(&slow, "slow", slow, `slow processing to clarify behavior`)
	flag.IntVar(&width, "width", width, `set concurrency width`)
	flag.Parse()

	// get fileInfoGroup
	fig, err := newFileInfoGroup("./testfiles")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	// get new conch and setup cleanup
	c := newConch(fig)

	sm.Set(func(s *sigmon.SignalMonitor) {
		close(c.doneChan())
	})

	// get fileOutput and error channels
	fos, errc := c.run()

	// print file contents
	for fo := range fos {
		fmt.Println(fo.path, fo.data, fo.err)<commit_msg>Call Stop() on signal monitor to prevent close on closed chan.<commit_after>package main

import (
	"flag"
	"fmt"
	"os"

	"github.com/codemodus/sigmon"
)

var (
	// slow enables a slowing of the digest function and may help users to
	// better understand the implementation of concurrency
	slow = false

	// width controls the amount of goroutines running the digest function
	width = 8
)

func main() {
	sm := sigmon.New(nil)
	sm.Run()

	// define and parse flags
	flag.BoolVar(&slow, "slow", slow, `slow processing to clarify behavior`)
	flag.IntVar(&width, "width", width, `set concurrency width`)
	flag.Parse()

	// get fileInfoGroup
	fig, err := newFileInfoGroup("./testfiles")
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}

	// get new conch and setup cleanup
	c := newConch(fig)

	sm.Set(func(s *sigmon.SignalMonitor) {
		close(c.doneChan())
		sm.Stop()
	})

	// get fileOutput and error channels
	fos, errc := c.run()

	// print file contents
	for fo := range fos {
		fmt.Println(fo.path, fo.data, fo.err)
{'fraction_non_alphanumeric': 0.13093453273363317, 'fraction_numerical': 0.001999000499750125, 'mean_word_length': 3.5294117647058822, 'pattern_counts': {'":': 0, '<': 3, '<?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': '384414', 'n_tokens_mistral': 736, 'n_tokens_neox': 690, 'n_words': 220}