Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context manager open(file) as f fixes #7289

Merged
merged 2 commits into from
Apr 5, 2022
Merged

Context manager open(file) as f fixes #7289

merged 2 commits into from
Apr 5, 2022

Conversation

glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Apr 5, 2022

Possible fix for #7288

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Enhanced file handling for better resource management in yolov5.

πŸ“Š Key Changes

  • Updated VOC.yaml to use a context manager for reading image ids.
  • Modified export.py to use a context manager when reading and rewriting JSON files.
  • Refactored models/common.py to parse GraphDef with a context manager.
  • Changed example_request.py in flask_rest_api to read image data within a context manager.
  • Small comment update in restapi.py, possibly for better documentation clarity.

🎯 Purpose & Impact

  • Improved Code Reliability: Using context managers (with statement) ensures files are properly closed after operations, reducing the likelihood of file handle leaks.
  • Resource Efficiency: This is a more resource-efficient way of handling files, which can slightly improve the performance of the system and avoid potential bugs in the long run.
  • Maintainability: These changes make the code more explicit and Pythonic, which is generally easier to read and maintain.

@glenn-jocher glenn-jocher self-assigned this Apr 5, 2022
@glenn-jocher glenn-jocher linked an issue Apr 5, 2022 that may be closed by this pull request
2 tasks
@glenn-jocher glenn-jocher mentioned this pull request Apr 5, 2022
2 tasks
@glenn-jocher glenn-jocher changed the title Flask context manager open() fix Context manager open(file) as f fixes Apr 5, 2022
@glenn-jocher glenn-jocher merged commit 5f97001 into master Apr 5, 2022
@glenn-jocher glenn-jocher deleted the fix/flask branch April 5, 2022 10:54
BjarneKuehl pushed a commit to fhkiel-mlaip/yolov5 that referenced this pull request Aug 26, 2022
* Flask context manager `open()` fix

* Additional read context manager fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flask Memory Release Error
1 participant