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

fix(upload-files): close file handle before handling error (DEV-2666) #519

Merged
merged 1 commit into from Sep 14, 2023

Conversation

jnussbaum
Copy link
Collaborator

No description provided.

@jnussbaum jnussbaum self-assigned this Sep 14, 2023
@linear
Copy link

linear bot commented Sep 14, 2023

DEV-2666 unclosed file handle in upload-files

In src/dsp_tools/fast_xmlupload/upload_files.py::upload_without_processing(), if an exception occurs during the requests.post(), the function _call_upload_without_processing_recursively() is called BEFORE CLOSING THE FILE (within the with block).

This caused the following error on Nora's machine:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/dsp_tools/fast_xmlupload/upload_files.py", line 209, in _upload_without_processing
    with open(file, "rb") as bitstream:
         ^^^^^^^^^^^^^^^^
OSError: [Errno 24] Too many open files: '/Volumes/LaCie2/tmp/fe/38/fe38d56b-8ea4-4383-85f5-466b33da9fd6.jp2'

@jnussbaum jnussbaum merged commit 439a139 into main Sep 14, 2023
4 checks passed
@jnussbaum jnussbaum deleted the wip/dev-2666-unclosed-file-handle branch September 14, 2023 15:09
@daschbot daschbot mentioned this pull request Sep 14, 2023
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.

None yet

2 participants