The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The goals of jobqueue are to:
# Install the latest stable version from CRAN:
install.packages("jobqueue")
# Or the development version from GitHub:
install.packages("pak")
::pak("cmmr/jobqueue") pak
library(jobqueue)
<- Queue$new()
q
<- q$run({ paste('Hello', 'world!') })
job $result
job#> [1] "Hello world!"
Main article: vignette('hooks')
<- q$run(
j expr = { 42 },
hooks = list(
'created' = ~{ message("We're uid '", .$uid, "'.") },
'*' = ~{ message(' - ', .$state) }))
#> We're uid 'J2'.
#> - created
#> - submitted
#> - queued
#> - assigned
#> - dispatched
#> - running
#> - done
$on('done', function (job) message('result = ', job$result))
j#> result = 42
<- q$run({ 3.14 })
job <- function (result) message('resolved with: ', result)
callback
%...>% callback
job #> resolved with: 3.14
%>% then(callback)
job #> resolved with: 3.14
as.promise(job)$then(callback)
#> resolved with: 3.14
See also https://rstudio.github.io/promises/
function(input, output, session) {
$plot <- renderPlot({
output$run({ read.table(url) }, list(url = input$url)) %...>%
qhead(input$n) %...>%
plot()
}) }
See also https://rstudio.github.io/promises/articles/promises_06_shiny.html
When a running job is stopped, the background process for it is terminated. Terminated background process are automatically replaced by new ones.
Stopped jobs will return a condition object of class ‘interrupt’ as their result.
Main article: vignette('stops')
<- q$run({ Sys.sleep(2); 'Zzzzz' })
job $stop()
job$result
job#> <interrupt: job stopped by user>
A custom message can also be given,
e.g. job$stop('my reason')
, which will be returned in the
condition object.
<- q$run({ Sys.sleep(2); 'Zzzzz' }, timeout = 0.2)
job $result
job#> <interrupt: total runtime exceeded 0.2 seconds>
Limits (in seconds) can be set on:
timeout = 2
timeout = list(queued = 1, running = 2)
timeout = list(total = 3, queued = 2, running = 2)
New jobs will replace existing jobs with the same
stop_id
.
<- q$run({ Sys.sleep(1); 'A' }, stop_id = 123)
job1 <- q$run({ 'B' }, stop_id = 123)
job2 $result
job1#> <interrupt: duplicated stop_id>
$result
job2#> [1] "B"
New jobs will mirror the output of existing jobs with the same
copy_id
.
<- q$run({ Sys.sleep(1); 'A' }, copy_id = 456)
job1 <- q$run({ 'B' }, copy_id = 456)
job2 $result
job1#> [1] "A"
$result
job2#> [1] "A"
<- Queue$new(globals = list(G = 8))
q <- quote(c(x = x , y = y, G = G))
expr <- q$run(expr, vars = list(x = 10, y = 2))
job
dput(job$result)
#> c(x = 10, y = 2, G = 8)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.