AsyncInterruptor | R Documentation |
An interruptor useful for stopping child processes.
An interruptor useful for stopping child processes.
This class is a simple wrapper around a Queue object making adding interrupt checking to future code easy to implement and read.
Methods
initialize(queue=shinyQueue())
Creates a new interruptor.
interrupt(msg="Signaled Interrupt")
Signals an interrupt
execInterrupts()
Executes anything pushed to the queue, including interrupts.
getInterrupts()
Gets the result of the queue's executing, not throwing the interrupts.
new()
Create the object
AsyncInterruptor$new(queue = shinyQueue())
queue
The underlying queue object to use for interruption
interrupt()
signal an error
AsyncInterruptor$interrupt(msg = "Signaled Interrupt")
msg
The error message
execInterrupts()
Execute any interruptions that have been signaled
AsyncInterruptor$execInterrupts()
getInterrupts()
Get any interruptions that have been signaled without throwing them as errors
AsyncInterruptor$getInterrupts()
destroy()
Cleans up object after use
AsyncInterruptor$destroy()
clone()
The objects of this class are cloneable with this method.
AsyncInterruptor$clone(deep = FALSE)
deep
Whether to make a deep clone.
library(future) strategy <- "future::multisession" plan(strategy) inter <- AsyncInterruptor$new() fut <- future({ for(i in 1:100){ Sys.sleep(.01) inter$execInterrupts() } }) inter$interrupt("Error: Stop Future") try(value(fut)) inter$destroy() # Clean up multisession cluster plan(sequential)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.