% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/job.R
\name{job_wait}
\alias{job_wait}
\title{Wait for a DNAnexus job to finish}
\usage{
job_wait(job_id, interval = 30, timeout = Inf, verbose = TRUE)
}
\arguments{
\item{job_id}{(character) Job ID returned by \code{extract_batch()}.}

\item{interval}{(integer) Polling interval in seconds. Default: \code{30}.}

\item{timeout}{(numeric) Maximum wait time in seconds. Default: \code{Inf}
(wait indefinitely). On UKB RAP, jobs can stay in \code{"runnable"} for
several hours during peak times — set a finite value (e.g. \code{7200})
only if you need a hard deadline.}

\item{verbose}{(logical) Print state and elapsed time at each poll.
Default: \code{TRUE}.}
}
\value{
Invisibly returns the final state string (\code{"done"}).
}
\description{
Polls \code{job_status()} at regular intervals until the job reaches a
terminal state (\code{"done"}, \code{"failed"}, or \code{"terminated"}).
Stops with an error if the job fails, is terminated, or times out.
}
\examples{
\dontrun{
job_id <- extract_batch(c(31, 53, 21022))
job_wait(job_id)

# Read result immediately after completion (RAP only)
job_wait(job_id)
df <- job_result(job_id)
}
}
