Fixed race condition

This commit is contained in:
Loweel 2019-12-11 16:22:15 +01:00
parent 690666c94a
commit 1d89cbf698

16
file.go
View file

@ -54,6 +54,9 @@ func saveBayesToFile() {
writeToFile(dumpfile+"stats.json", statsREPORT)
ZClassifier.Learning.busy.Lock()
defer ZClassifier.Learning.busy.Unlock()
badScores, err := json.MarshalIndent(ZClassifier.Learning.bayez.datas[Bad], "", " ")
if err != nil {
badScores = []byte(err.Error())
@ -71,19 +74,6 @@ func saveBayesToFile() {
log.Println(string(goodScores))
// dumpfile := os.Getenv("DUMPFILE")
// if dumpfile == "" {
// dumpfile = "bayes.json"
// }
// if DebugLog {
// log.Println("DUMP: ", string(tmpJSON)+statsREPORT)
// } else {
// writeToFile(dumpfile, string(tmpJSON)+statsREPORT)
//
// log.Println("File saved: ", dumpfile)
// }
}
func jsonEngine() {