From eb81b9c88c0c44593fbc6322c13daaa00be3c2af Mon Sep 17 00:00:00 2001 From: Igor Date: Sun, 2 Aug 2015 00:01:30 -0700 Subject: [PATCH] Fixes open source file never getting closed In a processes that generates many images, you could run into a cituation with too man files being open. This results in: IOError: [Errno 24] Too many open files --- imagekit/specs/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/imagekit/specs/__init__.py b/imagekit/specs/__init__.py index 054f3fd..829dce1 100644 --- a/imagekit/specs/__init__.py +++ b/imagekit/specs/__init__.py @@ -153,9 +153,11 @@ class ImageSpec(BaseImageSpec): self.source.open() img = open_image(self.source) - return process_image(img, processors=self.processors, - format=self.format, autoconvert=self.autoconvert, - options=self.options) + new_image = process_image(img, processors=self.processors, + format=self.format, autoconvert=self.autoconvert, + options=self.options) + self.source.close() + return new_image def create_spec_class(class_attrs):