MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / sleep_with_cancel

Function sleep_with_cancel

crates/opencode-session/src/retry.rs:14–21  ·  view source on GitHub ↗
(ms: u64, cancel: CancellationToken)

Source from the content-addressed store, hash-verified

12pub struct SleepCancelled;
13
14pub async fn sleep_with_cancel(ms: u64, cancel: CancellationToken) -> Result<(), SleepCancelled> {
15 let duration = Duration::from_millis(ms.min(RETRY_MAX_DELAY));
16
17 tokio::select! {
18 _ = sleep(duration) => Ok(()),
19 _ = cancel.cancelled() => Err(SleepCancelled),
20 }
21}
22
23pub fn delay(attempt: u32, error: Option<&ApiErrorInfo>) -> u64 {
24 if let Some(err) = error {

Callers 1

processMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected