code: def safe_makedirs(path):
      
      if not os.path.exists(path):
          try:
              os.makedirs(path)
          except OSError:
              if not os.path.exists(path):
                  raise
docs: Safe makedirs.
  
      Works in a multithreaded scenario.