pub async fn run(self, stop_receiver: watch::Receiver<bool>) -> anyhow::Result<()> {
        const SLEEP_INTERVAL: Duration = Duration::from_millis(50);

        let mut conn = self.pool.connection_tagged(self.io.name()).await?;
        let mut latest_processed_batch = self.io.latest_processed_batch(&mut conn).await?;
        drop(conn);
        loop {
            if *stop_receiver.borrow() {
                tracing::info!("`ConcurrentOutputHandlerFactoryTask` was interrupted");
                return Ok(());
            }
            match self.state.remove(&(latest_processed_batch + 1)) {
                None => {
                    tracing::debug!(
                        "Output handler for batch #{} has not been created yet",
                        latest_processed_batch + 1
                    );
                    tokio::time::sleep(SLEEP_INTERVAL).await;
                }
                Some((_, receiver)) => {
                    // Wait until the `JoinHandle` is sent through the receiver, happens when
                    // `handle_l1_batch` is called on the corresponding output handler
                    let handle = receiver
                        .await
                        .context("handler was dropped before the batch was fully processed")?;
                    // Wait until the handle is resolved, meaning that the `handle_l1_batch`
                    // computation has finished, and we can consider this batch to be completed
                    handle
                        .await
                        .context("failed to await for batch to be processed")??;
                    latest_processed_batch += 1;
                    let mut conn = self.pool.connection_tagged(self.io.name()).await?;
                    self.io
                        .mark_l1_batch_as_completed(&mut conn, latest_processed_batch)
                        .await?;
                    METRICS
                        .last_processed_batch
                        .set(latest_processed_batch.0.into());
                }
            }
        }
    }
Starts running the task which is supposed to last until the end of the node's lifetime.

# Errors

Propagates DB errors.
core/node/vm_runner/src/output_handler.rs