MCPcopy Index your code
hub / github.com/AI45Lab/Code / run_with_timeout

Method run_with_timeout

core/src/workspace/mod.rs:686–705  ·  view source on GitHub ↗

Run a workspace future under the configured operation timeout. Tools that route through file system / search / git providers should wrap their calls with this helper so non-local backends never stall the agent loop indefinitely. Polymorphic in the error type so the helper works equally well for futures returning `anyhow::Result ` (the legacy callers — search, git, etc.) and for futures returni

(
        &self,
        op: &'static str,
        fut: F,
    )

Source from the content-addressed store, hash-verified

684 /// [`WorkspaceError`] (via its `#[from]` `Backend` variant); a timeout
685 /// surfaces as that From conversion of an `anyhow!(...)` message.
686 pub async fn run_with_timeout<F, T, E>(
687 &self,
688 op: &'static str,
689 fut: F,
690 ) -> std::result::Result<T, E>
691 where
692 F: std::future::Future<Output = std::result::Result<T, E>>,
693 E: From<anyhow::Error>,
694 {
695 match self.operation_timeout {
696 Some(d) => tokio::time::timeout(d, fut).await.map_err(|_| {
697 E::from(anyhow!(
698 "workspace operation '{}' timed out after {:?}",
699 op,
700 d
701 ))
702 })?,
703 None => fut.await,
704 }
705 }
706
707 /// Read a file for a subsequent modify-write cycle, requesting a version
708 /// token when the backend supports compare-and-swap writes.

Callers 7

executeMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80
executeMethod · 0.80
read_for_editMethod · 0.80
write_for_editMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected