~egtann/sjs

9baf2a490419578d252f9505fc21a43a30be87aa — Evan Tann 1 year, 11 months ago 029e814
fix context cancel bug
1 files changed, 4 insertions(+), 4 deletions(-)

M job.go
M job.go => job.go +4 -4
@@ 190,14 190,14 @@ func recordJobResult(
func scheduleJobWithTimeout(workerMap *WorkerMap, j *Job) error {
	ctx := context.Background()
	var cancel context.CancelFunc
	if j.TimeoutInSeconds != nil {
	if j.TimeoutInSeconds == nil {
		ctx, cancel = context.WithCancel(ctx)
	} else {
		t := time.Duration(*j.TimeoutInSeconds) * time.Second
		ctx, cancel = context.WithTimeout(ctx, t)
	}
	defer cancel()
	err := run(ctx, workerMap, j)
	if j.TimeoutInSeconds != nil {
		cancel()
	}
	return errors.Wrap(err, "run")
}