diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-12-24 20:40:30 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-12-24 20:40:30 +0100 |
commit | 6a6894811294be1d57ebfc074e6e7ab47838dadb (patch) | |
tree | f492e62a39a7f5d0a1e223bf3a25296cd70b70bf /src/exiv2wrapper.cpp | |
parent | 504a6a80e0de8122b6107c2b64cb86cea65b742c (diff) | |
download | pyexiv2-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.cpp | 14 |
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() |