GithubHelp home page GithubHelp logo

Comments (4)

victordomingos avatar victordomingos commented on May 28, 2024

Hmm. I believe I have also seen that kind of error, but at the time I couldn’t determine what was causing it, probably because it was a rare occurrence in my case. I need to take another look at it, but you’re probably right concerning the possibility of this being a race condition.

Currently the temporary files are being created in the same folder that has the original file, with a prefix in the name. Maybe it needs to be set to ignore any image files whose name starts with that prefix. Or maybe the temporary file can be replaced with something in memory without disk I/O, which should be much faster and would probably solve this issue.

from optimize-images.

varnav avatar varnav commented on May 28, 2024

Looks like it's more likely to occur on fast hardware - I have 12 core CPU and NVMe SSD. I noticed that if system is under load - this is less likely to occur. Of course it would be the best not to create temp file at all. Maybe this will help: https://docs.python.org/3/library/tempfile.html#tempfile.SpooledTemporaryFile

from optimize-images.

victordomingos avatar victordomingos commented on May 28, 2024

Thank you very much for your feedback. I submitted a quick fix, just checking the presence of the temporary files prefix (~temp~) in the filename. It should be enough to avoid the reported issue. I will keep in mind your SpooledTemporaryFile suggestion, though.

Please let me know in case you still get any issue with this version.

from optimize-images.

victordomingos avatar victordomingos commented on May 28, 2024

Just a quick notice to let you know that, on the latest commit (not yet available in PyPI), I have implemented in-memory buffers using BytesIO, instead of in-disk temporary files. Still under testing, as the refactoring could have introduced some regression bugs.

I am still curious about any potential advantages of SpooledTemporaryFile over BytesIO, though.

from optimize-images.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.