Here are the internals of os.makedirs:
def makedirs(name, mode=0777):
"""makedirs(path [, mode=0777])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
just the rightmost) will be created if it does not exist. This is
recursive.
"""
head, tail = path.split(name)
if not tail:
head, tail = path.split(head)
if head and tail and not path.exists(head):
try:
makedirs(head, mode)
except OSError, e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists
return
mkdir(name, mode)
The above is just pure Python, except for references into the
Modules/posixmodule.c, e.g., the definition of mkdir is here:
https://github.com/python/cpython/blob/master/Modules/posixmodule.c#L3948
Anyway, the way you describe the problem, suggests to me that maybe
your filesystem or container is somehow not telling the truth to the
OS. E.g., maybe you have some sort of filesystem caching enabled,
which makes things seem way faster, but is dangerous and not
compliant... I don't know. Does the problem go away when you use
ext4 outside a container?
-- William
--
William (
http://wstein.org)