From 0419aee83e1a3bc5f256480cc9591f19e97cbc5e Mon Sep 17 00:00:00 2001 From: Nick White Date: Wed, 16 Oct 2019 15:59:40 +0100 Subject: Another attempted fix to "too many open files" issue --- cmd/booktopipeline/main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/booktopipeline/main.go b/cmd/booktopipeline/main.go index 6e10475..a455966 100644 --- a/cmd/booktopipeline/main.go +++ b/cmd/booktopipeline/main.go @@ -118,7 +118,7 @@ func main() { if err != nil { log.Fatalln("Open file", path, "failed:", err) } - defer file.Close() + //defer file.Close() // done explicitly below _, err = uploader.Upload(&s3manager.UploadInput{ Bucket: aws.String("rescribeinprogress"), Key: aws.String(filepath.Join(bookname, name)), @@ -130,7 +130,10 @@ func main() { // Explicitly close here rather than wait for the defer, so we // don't end up with too many open files which can cause os.Open // to fail. - file.Close() + err = file.Close() + if err != nil { + log.Fatalln("Failed to close file", path, err) + } } verboselog.Println("Sending message", bookname, "to queue", qurl) -- cgit v1.2.1-24-ge1ad