Allow pickling of FileLayers by unsetting the file (it'll be reopened as soon as a read happens).

This commit is contained in:
Mike Auty
2016-12-25 00:02:42 +00:00
parent e230bbf6a8
commit 60bf657895
+8
View File
@@ -130,6 +130,14 @@ class FileLayer(interfaces.layers.DataLayerInterface):
self._file.seek(offset)
self._file.write(data)
def __getstate__(self):
"""Do not store the open _file_ attribute, our property will ensure the file is open when needed
This is necessary for multi-processing
"""
self._file_ = None
return self.__dict__
def destroy(self):
"""Closes the file handle"""
self._file.close()