diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-12-21 21:15:41 +0100 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-12-21 21:15:41 +0100 |
commit | 504a6a80e0de8122b6107c2b64cb86cea65b742c (patch) | |
tree | e122810211d95e38b18d6ecb45926ebe10f1a1ff /src/exiv2wrapper.cpp | |
parent | 6ed0e297b305f0b6cfaebc24e4a0de4cf39d9d17 (diff) | |
download | pyexiv2-504a6a80e0de8122b6107c2b64cb86cea65b742c.tar.gz |
Release the GIL while reading/writing metadata.
This allows other python threads to continue running while costly IO operations are being performed.
Also, this is my in-flight commit (somewhere between Barcelona and Paris).
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 61c0d9a..f5e6b80 100644 --- a/src/exiv2wrapper.cpp +++ b/src/exiv2wrapper.cpp @@ -57,21 +57,35 @@ Image::Image(const Image& image) void Image::readMetadata() { + // Release the GIL to allow other python threads to run + // while reading metadata. + Py_BEGIN_ALLOW_THREADS + _image->readMetadata(); _exifData = _image->exifData(); _iptcData = _image->iptcData(); _xmpData = _image->xmpData(); _dataRead = true; + + // Re-acquire the GIL + Py_END_ALLOW_THREADS } void Image::writeMetadata() { if(_dataRead) { + // Release the GIL to allow other python threads to run + // while writing metadata. + Py_BEGIN_ALLOW_THREADS + _image->setExifData(_exifData); _image->setIptcData(_iptcData); _image->setXmpData(_xmpData); _image->writeMetadata(); + + // Re-acquire the GIL + Py_END_ALLOW_THREADS } else throw Exiv2::Error(METADATA_NOT_READ); |