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

create_directory_if_needed race condition #169

Open
apmorton opened this issue Jul 24, 2024 · 0 comments · May be fixed by #171
Open

create_directory_if_needed race condition #169

apmorton opened this issue Jul 24, 2024 · 0 comments · May be fixed by #171

Comments

@apmorton
Copy link

approvaltests/file_approver.py:54: in verify
    received = writer.write_received_file(received)
approvaltests/string_writer.py:33: in write_received_file
    create_directory_if_needed(received_file)
approval_utilities/utils.py:69: in create_directory_if_needed
    os.makedirs(directory)
<frozen os>:225: in makedirs
    ???
E   FileExistsError: [Errno 17] File exists: '/some/directory/here'

If multiple tests are running in parallel and attempting to write different files in the same directory they may race to create the directory and fail.

create_directory_if_needed should not check for existence and conditionally call os.makedirs, it should call os.makedirs(path, exist_ok=True) unconditionally.

@apmorton apmorton linked a pull request Aug 23, 2024 that will close this issue
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 a pull request may close this issue.

1 participant