[ python-Bugs-1149804 ] macostools.mkdirs: not thread-safe

SourceForge.net noreply at sourceforge.net
Wed Feb 23 14:26:43 CET 2005


Bugs item #1149804, was opened at 2005-02-23 13:26
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1149804&group_id=5470

Category: Macintosh
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Jurjen N.E. Bos (jneb)
Assigned to: Jack Jansen (jackjansen)
Summary: macostools.mkdirs: not thread-safe

Initial Comment:
Here is an easily fixable semi-bug in macostools:
When two threads are creating the same directory structure, one 
of them will fail as soon as the other thread made a directory.
This is trivially fixable by ignoring the error, but I'm not sure if it is 
worth it, like this:

def mkdirs(dst):
    """Make directories leading to 'dst' if they don't exist yet"""
    if dst == '' or os.path.exists(dst):
        return
    head, tail = os.path.split(dst)
    if os.sep == ':' and not ':' in head:
        head = head + ':'
    mkdirs(head)
    try: os.mkdir(dst, 0777)
    except OSError, err:
	if err.errno==17: #file exists
		#someone else has created the directory in the 
meantime. That's fine with me!
		pass
	else: raise
- Jurjen

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1149804&group_id=5470


More information about the Python-bugs-list mailing list