[ python-Bugs-1149804 ] macostools.mkdirs: not thread-safe
SourceForge.net
noreply at sourceforge.net
Tue Mar 1 09:49:49 CET 2005
Bugs item #1149804, was opened at 2005-02-23 14:26
Message generated for change (Comment added) made by jvr
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
----------------------------------------------------------------------
>Comment By: Just van Rossum (jvr)
Date: 2005-03-01 09:49
Message:
Logged In: YES
user_id=92689
Oops, disregard that portability remark, it does work correctly in non-OS9
Python as well. I _think_ macostools.mkdirs() predates os.makedirs(), it's
probably best considered deprecated.
----------------------------------------------------------------------
Comment By: Just van Rossum (jvr)
Date: 2005-03-01 09:40
Message:
Logged In: YES
user_id=92689
Hm, macostools.mkdirs() also isn't portable: it only works on OS9
MacPython. Why don't you use os.makedirs() instead? (Which appears to
have the same threads issue, though.)
----------------------------------------------------------------------
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