From 0535e0af36a90d3c18efe1360d3fc0f786fd8a1d Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 25 Nov 2019 21:50:51 -0500 Subject: [PATCH] don't try shrinking too many images at once --- backend.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/backend.go b/backend.go index 5d61147..ca7ba1e 100644 --- a/backend.go +++ b/backend.go @@ -23,6 +23,7 @@ import ( "os" "os/exec" + "humungus.tedunangst.com/r/webs/gate" "humungus.tedunangst.com/r/webs/image" ) @@ -38,7 +39,11 @@ type ShrinkerResult struct { Image *image.Image } +var shrinkgate = gate.NewLimiter(4) + func (s *Shrinker) Shrink(args *ShrinkerArgs, res *ShrinkerResult) error { + shrinkgate.Start() + defer shrinkgate.Finish() img, err := image.Vacuum(bytes.NewReader(args.Buf), args.Params) if err != nil { return err