cgohlke / imagecodecs

Image transformation, compression, and decompression codecs
https://pypi.org/project/imagecodecs
BSD 3-Clause "New" or "Revised" License
117 stars 23 forks source link

imagecodecs.numcodecs.register_codecs: RuntimeError #63

Closed ap-- closed 1 year ago

ap-- commented 1 year ago

Hi @cgohlke,

In a CI run, I just saw a RuntimeError: dictionary changed size during iteration in register_codecs It only failed on Python3.11 on ubuntu. And rerunning the job could not reproduce the error, so this might be just some artefact.

Reporting it just in case it pops up again.

https://github.com/bayer-science-for-a-better-life/tiffslide/actions/runs/4292134595/jobs/7478191925#step:6:257

imagecodecs-2023.1.23 numcodecs-0.11.0

[...]
>       ts = from_kerchunk(kc)

tiffslide/tests/test_kerchunk.py:28: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tiffslide/_kerchunk.py:155: in from_kerchunk
    register_codecs(verbose=False)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

codecs = None, force = False, verbose = False

    def register_codecs(codecs=None, force=False, verbose=True):
        """Register codecs in this module with numcodecs."""
>       for name, cls in globals().items():
E       RuntimeError: dictionary changed size during iteration

/opt/hostedtoolcache/Python/3.11.2/x64/lib/python3.11/site-packages/imagecodecs/numcodecs.py:1339: RuntimeError

Cheers, Andreas

cgohlke commented 1 year ago

Strange, register_codecs should not modify the module's globals dict, neither should the numcodecs functions. Anyway, I'll change it to list(globals().items()).

Is register_codecs called from different threads or is the imagecodecs-numcodecs package installed?

ap-- commented 1 year ago

imagecodecs-numcodecs is not installed in the CI and the crash occurred when running pytest. But I can't reproduce locally and it hasn't occurred since in the CI.

Maybe it was just some single event error on the runner šŸ¤·