- warn instead of raise error when file is empty upon closing
This commit is contained in:
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open('README.md', 'r') as fh:
|
||||
|
||||
setuptools.setup(
|
||||
name='tiffwrite',
|
||||
version='2022.5.4',
|
||||
version='2022.6.0',
|
||||
author='Wim Pomp @ Lenstra lab NKI',
|
||||
author_email='w.pomp@nki.nl',
|
||||
description='Parallel tiff writer compatible with ImageJ.',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import os
|
||||
import tifffile
|
||||
import colorcet
|
||||
import struct
|
||||
@@ -485,10 +486,14 @@ class IJTiffFile:
|
||||
dtype=int).T.flatten()]) for color in self.colors]
|
||||
|
||||
def close(self):
|
||||
assert len(self.frames_added) >= 1, 'at least one frame should be added to the tiff'
|
||||
if multiprocessing.current_process().pid == self.main_pid:
|
||||
self.pool_manager.close(self)
|
||||
with self.fh.lock() as fh:
|
||||
if len(self.frames_added) == 0:
|
||||
warn('At least one frame should be added to the tiff, removing file.')
|
||||
fh.close()
|
||||
os.remove(self.path)
|
||||
else:
|
||||
if len(self.frames_written) < np.prod(self.shape): # add empty frames if needed
|
||||
for n in product(*[range(i) for i in self.shape]):
|
||||
if n not in self.frames_written:
|
||||
@@ -598,6 +603,7 @@ class PoolManager:
|
||||
self.tifs.pop(tif.path)
|
||||
if not self.tifs:
|
||||
self.__class__.instance = None
|
||||
if self.is_alive:
|
||||
self.is_alive = False
|
||||
self.done.set()
|
||||
while not self.queue.empty():
|
||||
|
||||
Reference in New Issue
Block a user