<commit_before>package main

import "fmt"
import "os"

import "github.com/go-redis/redis"
import "github.com/joho/godotenv"

//import "github.com/stianeikeland/go-rpio"

func main() {
	godotenv.Load()

	redisChannelName := os.Getenv("UNSPEAK_CHANNEL_SPOKEN")
	redisAddress := os.Getenv("UNSPEAK_REDIS_ADDRESS")

	client := redis.NewClient(&redis.Options{
		Addr:     redisAddress,
		Password: "", // no password set
		DB:       0,  // use default DB
	})
	defer client.Close()

	pubsub := client.Subscribe(redisChannelName)
	defer pubsub.Close()

	done := make(chan bool)
	msg := make(chan string)

	go pinWorker(msg)
	go redisWorker(pubsub, msg, done)

	//Wait until we are Done...
	<-done

	fmt.Println("Exiting")
}

func redisWorker(pubsub *redis.PubSub, msg chan<- string, done chan<- bool) {
	for {
		message, err := pubsub.ReceiveMessage()
		if err != nil {
			break
		}
		msg <- message.Payload
	}
	close(msg)
	done <- true
}

func pinWorker(msg <-chan string) {

	// err := rpio.Open(); err != nil {
	// 	fmt.Println(err)
	// 	os.Exit(1)
	// }
<commit_msg>Isoalted the Redis Client in the worker function Moved the redis client's initialization to the redisWorker function for better isolation<commit_after>package main

import "fmt"
import "os"

import "github.com/go-redis/redis"
import "github.com/joho/godotenv"

//import "github.com/stianeikeland/go-rpio"

func main() {
	godotenv.Load()

	redisChannelName := os.Getenv("UNSPEAK_CHANNEL_SPOKEN")
	redisAddress := os.Getenv("UNSPEAK_REDIS_ADDRESS")

	done := make(chan bool)
	msg := make(chan string)

	go pinWorker(msg)
	go redisWorker(redisAddress, redisChannelName, msg, done)

	//Wait until we are Done...
	<-done

	fmt.Println("Exiting")
}

func redisWorker(redisAddress string, redisChannelName string, msg chan<- string, done chan<- bool) {
	client := redis.NewClient(&redis.Options{
		Addr:     redisAddress,
		Password: "", // no password set
		DB:       0,  // use default DB
	})
	defer client.Close()

	pubsub := client.Subscribe(redisChannelName)
	defer pubsub.Close()

	for {
		message, err := pubsub.ReceiveMessage()
		if err != nil {
			break
		}
		msg <- message.Payload
	}
	close(msg)
	done <- true
}

func pinWorker(msg <-chan string) {

	// err := rpio.Open(); err != nil {
	// 	fmt.Println(err)
	// 	os.Exit(1)
	// }

{'fraction_non_alphanumeric': 0.14403829416884248, 'fraction_numerical': 0.0017406440382941688, 'mean_word_length': 3.6164658634538154, 'pattern_counts': {'":': 0, '<': 15, '<?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': '1673586', 'n_tokens_mistral': 898, 'n_tokens_neox': 839, 'n_words': 200}