检查网络服务器 R 上的作业状态

Checking for the status of a job on the webserver R

我正在使用下面的这个函数执行 getURL 命令来检查服务器上任务的状态。

getURL(content(t2)$statusURL)

状态可以是 "Processing"(任务正在进行中)或 "Completed_Successfully"(任务完成时)。

只有当任务状态为"Completed_Successfully"时才会执行下面的代码

  getURL(content(t2)$ouptputURL)

如果任务状态仍然是 "Processing",代码应该等到它变为 "Completed_Successfully"

需要帮助在 R 中编写此逻辑?

几年前我遇到过类似的问题。我决定让 Windows 任务管理器(是的,我犯了罪)定期 运行 一个特定的脚本。您的脚本可能符合

isok <- FALSE
i <- 1
while (isok == FALSE) {
  record.start <- Sys.time()
  message("Checking if job done")
  Sys.sleep(i)
  record.end <- Sys.time()
  see.difference <- record.end - record.start
  message(paste("Waiting time:", round(see.difference)))
  if (see.difference >= 5) {
    isok <- TRUE
    message("Job completed")
  }
  i <- i + 1
}

Checking if job done
Waiting time: 1
Checking if job done
Waiting time: 2
Checking if job done
Waiting time: 3
Checking if job done
Waiting time: 4
Checking if job done
Waiting time: 5
Job completed