Fix thread safe branch
Add several fixes to the thread-safe
branch:
- Fix usage of
threading.local
: it is not a submodule that could be imported, but a class that need to be instantiated. Add new class_Python_Magic
as a wrapper around thepython-magic
call that manages the thread local memory to keep theMagic()
object. - Don't import
magic.compat
as it is not used anyway. - Move the whole logic to find a usable magic library in the present environment out of class
ThumbnailBackend
into a helper class_Magic
. - Fix the call of
puremagic
: need to add amime=True
argument
Note that this implementation explicitly drops support for libmagic
's own python bindings. The previous code in branch thread-safe
already (inadvertently?) broke it, so this is not a change in practice. If you want to readd libmagic
python binding support, you'd need to add yet another helper similar to class _Python_Magic
. But then, you'd need to wade your path through libmagic
internals, how their Magic()
object needs to be called, and these internals are awkward, so I'm not sure if that is worth it.
I also didn't bother to fix the dependencies in pyproject.toml
.
Edited by Rolf Krahl