Wait for a Slurm job to be completed

wait_slurm(x, ...)

# S3 method for slurm_job
wait_slurm(x, ...)

# S3 method for integer
wait_slurm(x, timeout = -1, freq = 0.1, force = TRUE, ...)

Arguments

x

Either a job id number, or an object of class slurm_job.

...

Further arguments passed to the method

timeout

Integer. Maximum wait time in seconds. If timeout < 0 then the command will only return when the job finishes.

freq

Frequency in seconds to query for the state of the job.

force

Logical scalar. When TRUE, if the job is not found after checking for its status, the function will continue to wait still.

Value

Invisible NULL.

Examples

# Waiting is only available if there are Slurm clusters
if (slurm_available()) {
  job <- Slurm_EvalQ(Sys.sleep(1000), plan = "submit", njobs = 2)
  wait_slurm(job, timeout = 1) # This will return a warning
  scancel(job)   
  Slurm_clean(job)
}