Skip to content

Commit

Permalink
Update scheduler.go to close file descriptor after encoding items
Browse files Browse the repository at this point in the history
  • Loading branch information
WangYihang committed Aug 29, 2024
1 parent e7537f8 commit 0409504
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,13 @@ func chanRecorder[T *basicTask | Status | schedulerMetadata](path string, ch <-c
return
}
go func() {
defer fd.Close()
encoder := json.NewEncoder(fd)
for item := range ch {
if err := encoder.Encode(item); err != nil {
slog.Error("error occurred while serializing data", slog.String("path", path), slog.String("error", err.Error()))
}
}
fd.Close()
wg.Done()
}()
}
Expand Down

0 comments on commit 0409504

Please sign in to comment.