def makedirs_safe(path, mode=None):
 rpath = unfrackpath(path)
 b_rpath = to_bytes(rpath)
 if (not os.path.exists(b_rpath)):
  try:
   if mode:
    os.makedirs(b_rpath, mode)
   else:
    os.makedirs(b_rpath)
  except OSError as e:
   if (e.errno != EEXIST):
    raise AnsibleError(('Unable to create local directories(%s): %s' % (to_native(rpath), to_native(e))))

def makedirs_safe ( path , mode = None ) : rpath = unfrackpath ( path ) b_rpath = to_bytes ( rpath ) if ( not os . path . exists ( b_rpath ) ) : try : if mode : os . makedirs ( b_rpath , mode ) else : os . makedirs ( b_rpath ) except OSError as e : if ( e . errno != EEXIST ) : raise AnsibleError ( ( 'Unable to create local directories(%s): %s' % ( to_native ( rpath ) , to_native ( e ) ) ) )
safe way to create dirs in muliprocess/thread environments .