def safe_makedirs(path):
if not os.path.exists(path):<EOL><INDENT>try:<EOL><INDENT>os.makedirs(path)<EOL><DEDENT>except OSError:<EOL><INDENT>if not os.path.exists(path):<EOL><INDENT>raise<EOL><DEDENT><DEDENT><DEDENT>
Safe makedirs.

    Works in a multithreaded scenario.