refactor(git): the retry wait and the clone limit share one off-the-runtime wrapper
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 11m19s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-09 16:25:11 +02:00
1 parent 9579bf44d5
commit a5720f9fa3
2 files changed
+5 -13

No files matched your search

+1 -1
View File
@@ -87,7 +87,7 @@ impl Drop for HostPermit {
/// Run blocking `work` without stalling the async runtime: on a multi-thread
/// runtime's worker, `block_in_place` moves the worker's other tasks first.
fn off_the_runtime<R>(work: impl FnOnce() -> R) -> R {
pub(crate) fn off_the_runtime<R>(work: impl FnOnce() -> R) -> R {
let on_multi_thread_runtime = tokio::runtime::Handle::try_current()
.is_ok_and(|h| h.runtime_flavor() == tokio::runtime::RuntimeFlavor::MultiThread);
if on_multi_thread_runtime {
+4 -12
View File
@@ -108,19 +108,11 @@ pub fn is_transient(error: &git2::Error) -> bool {
}
}
/// Wait `duration` on this thread. Clones run on the async runtime's worker
/// threads; `block_in_place` hands this worker's other tasks to another
/// worker first, so a waiting retry does not stall them.
/// Wait `duration` on this thread, without stalling the async runtime's
/// other tasks (clones run on its worker threads).
fn sleep(duration: Duration) {
if duration.is_zero() {
return;
}
let on_multi_thread_runtime = tokio::runtime::Handle::try_current()
.is_ok_and(|h| h.runtime_flavor() == tokio::runtime::RuntimeFlavor::MultiThread);
if on_multi_thread_runtime {
tokio::task::block_in_place(|| std::thread::sleep(duration));
} else {
std::thread::sleep(duration);
if !duration.is_zero() {
crate::pipeline::clone_limit::off_the_runtime(|| std::thread::sleep(duration));
}
}