This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Race condition in os.makedirs
Type: Stage:
Components: Library (Lib) Versions:
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, hanwen, jbowes
Priority: normal Keywords: patch

Created on 2006-12-04 16:52 by jbowes, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
mkdirs-catch jbowes, 2006-12-04 16:52
Messages (3)
msg51471 - (view) Author: James Bowes (jbowes) Date: 2006-12-04 16:52
os.makedirs first checks if the non-leaf part of the path exists, and then calls makedirs on this part of the path to create it. If the path is created in between the call to path.exists, and the recursive call to os.makedirs, then  os.makedirs will raise an exception.

The attached patch catches this exception, and then tests if the exception is caused by a the file/directory's existence. If it is, the exception is ignored. If not, it is rasied.
msg51472 - (view) Author: Han-Wen Nienhuys (hanwen) * Date: 2006-12-05 23:58
looks good to me.
msg51473 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-12-09 09:10
Committed as rev. 52972, 52973 (2.5).
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44301
2006-12-04 16:52:43jbowescreate