Skip to main content

execute_in_background

Function execute_in_background 

Source
pub fn execute_in_background(
    pipeline: Arc<Pipeline>,
    inputs: Vec<Arc<dyn Value>>,
    ctx: Arc<TaskContext>,
    watcher: Arc<dyn PipelineWatcher>,
) -> PipelineRunHandle
Expand description

Spawn execute on the current Tokio runtime and return a PipelineRunHandle immediately.

The pipeline, context, and watcher must be owned (Arc) since the spawned task is 'static. Equivalent to Python’s run_pipeline_as_background_process.

let handle = execute_in_background(
    Arc::new(pipeline),
    vec![input],
    ctx,
    Arc::new(NoopWatcher),
);
// ... do other work ...
let result = handle.wait().await?;