aboutsummaryrefslogtreecommitdiffstats
path: root/src/exiv2wrapper.cpp
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-12-24 20:40:30 +0100
committerOlivier Tilloy <olivier@tilloy.net>2009-12-24 20:40:30 +0100
commit6a6894811294be1d57ebfc074e6e7ab47838dadb (patch)
treef492e62a39a7f5d0a1e223bf3a25296cd70b70bf /src/exiv2wrapper.cpp
parent504a6a80e0de8122b6107c2b64cb86cea65b742c (diff)
downloadpyexiv2-6a6894811294be1d57ebfc074e6e7ab47838dadb.tar.gz
Also release the GIL when opening a file,
this is a potentially long-running blocking IO operation.
Diffstat (limited to 'src/exiv2wrapper.cpp')
-rw-r--r--src/exiv2wrapper.cpp14
1 files changed, 14 insertions, 0 deletions
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()