AllenCellModeling / czifile

czi reader from https://www.lfd.uci.edu/~gohlke/code/czifile.py.html
BSD 3-Clause "New" or "Revised" License
15 stars 6 forks source link

Windows (virtual machine) and max_workers #1

Closed sheinb closed 5 years ago

sheinb commented 6 years ago

I've been experimenting with the library on macos, linux, and windows (which generally work great, thank you!) and I encountered a small problem on Windows (10) running in a VM (VMWare) on my mac. The call:

img = czi.asarray()

with no arguments, raises the following error:

C:\Users\sheinb\Anaconda3\lib\site-packages\czifile\czifile.py in func(directory_entry, resize, order, start, out)
    393                  start=self.start, out=out):
    394             """Read, decode, and copy subblock data."""
--> 395             subblock = directory_entry.data_segment()
    396             tile = subblock.data(resize=resize, order=order)
    397             index = [slice(i-j, i-j+k) for i, j, k in
AttributeError: 'list' object has no attribute 'data_segment'

This virtual machine has 2 CPUs assigned, and multiprocessor.cpu_count seems to report this correctly. I found, though, if I explicitly pass max_workers as 2, then the call works but if I pass max_workers as 1, it does not. Probably a rare issue (since everyone presumably has >1 CPU) but maybe there's a small issue is this part of the code? My knowledge of executor maps is limited...

       if max_workers > 1:
            self._fh.lock = True
            with ThreadPoolExecutor(max_workers) as executor:
                executor.map(func, self.filtered_subblock_directory)
            self._fh.lock = None
        else:
            func(self.filtered_subblock_directory)
cgohlke commented 6 years ago

func(self.filtered_subblock_directory)should be for directory_entry in self.filtered_subblock_directory: func(directory_entry)

cdw commented 6 years ago

👍

Should be fixed in 79b9fa59604e8b297faa055f766e8f36bc31a7eb