<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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