A makedirs that avoids a race conditions for multiple processes attempting to create the same directory.

def makedirs(p):
    """
    A makedirs that avoids a race conditions for multiple processes attempting to create the same directory.
    """
    try:
        os.makedirs(p, settings.FILE_UPLOAD_PERMISSIONS)
    except OSError:
        # Perhaps someone beat us to the punch?
        if not os.path.isdir(p):
            # Nope, must be something else...
            raise