def get_fd_or_server(config):
 lockfile = get_lockfile(config)
 while True:
  try:
   return (os.open(lockfile, ((os.O_CREAT | os.O_EXCL) | os.O_WRONLY)), None)
  except OSError:
   pass
  server = get_server(config)
  if (server is not None):
   return (None, server)
  remove_lockfile(lockfile)

def get_fd_or_server ( config ) : lockfile = get_lockfile ( config ) while True : try : return ( os . open ( lockfile , ( ( os . O_CREAT | os . O_EXCL ) | os . O_WRONLY ) ) , None ) except OSError : pass server = get_server ( config ) if ( server is not None ) : return ( None , server ) remove_lockfile ( lockfile )
tries to create the lockfile .