From 6a6894811294be1d57ebfc074e6e7ab47838dadb Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Thu, 24 Dec 2009 20:40:30 +0100 Subject: Also release the GIL when opening a file, this is a potentially long-running blocking IO operation. --- src/exiv2wrapper.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/exiv2wrapper.cpp') diff --git a/src/exiv2wrapper.cpp b/src/exiv2wrapper.cpp index f5e6b80..4a3f0f6 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -40,19 +40,33 @@ namespace exiv2wrapper // Base constructor Image::Image(const std::string& filename) { + // Release the GIL to allow other python threads to run + // while opening the file. + Py_BEGIN_ALLOW_THREADS + _filename = filename; _image = Exiv2::ImageFactory::open(filename); assert(_image.get() != 0); _dataRead = false; + + // Re-acquire the GIL + Py_END_ALLOW_THREADS } // Copy constructor Image::Image(const Image& image) { + // Release the GIL to allow other python threads to run + // while opening the file. + Py_BEGIN_ALLOW_THREADS + _filename = image._filename; _image = Exiv2::ImageFactory::open(_filename); assert(_image.get() != 0); _dataRead = false; + + // Re-acquire the GIL + Py_END_ALLOW_THREADS } void Image::readMetadata() -- cgit