<commit_before>package main

import (
	"github.com/dshearer/jobber/common"
	"os"
)

func (self *JobManager) doReloadCmd(cmd common.ReloadCmd) {
	defer close(cmd.RespChan)

	// read job file
	newJfile, err := self.loadJobFile()
	if err != nil && !os.IsNotExist(err) {
		cmd.RespChan <- &common.ReloadCmdResp{Err: err}
		close(cmd.RespChan)
		return
	}

	// stop job-runner thread and wait for current runs to end
	self.jobRunner.Cancel()
	for rec := range self.jobRunner.RunRecChan() {
		self.handleRunRec(rec)
	}
	self.jobRunner.Wait()

	// set new job file
	self.jfile = newJfile

	// restart job-runner thread
	self.jobRunner.Start(self.jfile.Jobs, self.Shell,
		self.mainThreadCtx)

	// make response
	cmd.RespChan <- &common.ReloadCmdResp{
		NumJobs: len(self.jfile.Jobs),
	}
}
<commit_msg>(#122) Bugfix: 'jobber status' hangs<commit_after>package main

import (
	"github.com/dshearer/jobber/common"
	"os"
)

func (self *JobManager) doReloadCmd(cmd common.ReloadCmd) {
	defer close(cmd.RespChan)

	// read job file
	newJfile, err := self.loadJobFile()
	if err != nil && !os.IsNotExist(err) {
		cmd.RespChan <- &common.ReloadCmdResp{Err: err}
		return
	}

	// stop job-runner thread and wait for current runs to end
	self.jobRunner.Cancel()
	for rec := range self.jobRunner.RunRecChan() {
		self.handleRunRec(rec)
	}
	self.jobRunner.Wait()

	// set new job file
	self.jfile = newJfile

	// restart job-runner thread
	self.jobRunner.Start(self.jfile.Jobs, self.Shell,
		self.mainThreadCtx)

	// make response
	cmd.RespChan <- &common.ReloadCmdResp{
		NumJobs: len(self.jfile.Jobs),
	}
}

{'fraction_non_alphanumeric': 0.13656387665198239, 'fraction_numerical': 0.0018879798615481435, 'mean_word_length': 3.8328267477203646, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6508792', 'n_tokens_mistral': 651, 'n_tokens_neox': 602, 'n_words': 127}