Safe makedirs.

    Works in a multithreaded scenario.

def safe_makedirs(path):
    """Safe makedirs.

    Works in a multithreaded scenario.
    """
    if not os.path.exists(path):
        try:
            os.makedirs(path)
        except OSError:
            if not os.path.exists(path):
                raise