Skip to content

FIX: set exist_ok=True in os.makedirs() #120

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

Merged
merged 1 commit into from
Jul 20, 2025

Conversation

Dengda98
Copy link
Contributor

replaces a non-atomic pattern for directory creation:

if not os.path.exists(dirname):
    os.makedirs(dirname)

with the safer:

os.makedirs(dirname, exist_ok=True)

In the parallel state (merged in #110 ), the original pattern is prone to race conditions: two processes may check for directory existence and both attempt to create it at the same time, will case FileExistsError. Using exist_ok=True makes directory creation atomic and thread-safe.

@Dengda98
Copy link
Contributor Author

Can it be merged?

@shimizukawa shimizukawa merged commit 6d36662 into sphinx-doc:master Jul 20, 2025
8 checks passed
@shimizukawa
Copy link
Member

Thanks!

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.

3 participants