MCPcopy Create free account
hub / github.com/WeaveMindAI/weft / e2b_semaphore

Function e2b_semaphore

catalog/code/:exec/python/backend.rs:77–88  ·  view source on GitHub ↗

Global per-replica concurrency gate for E2B sandbox creation. Enforced across all concurrent ExecPython executions in a single node-runner process. Sized from E2B_CONCURRENCY env var (falls back to E2B_DEFAULT_CONCURRENCY).

()

Source from the content-addressed store, hash-verified

75/// across all concurrent ExecPython executions in a single node-runner process.
76/// Sized from E2B_CONCURRENCY env var (falls back to E2B_DEFAULT_CONCURRENCY).
77fn e2b_semaphore() -> &'static Semaphore {
78 static SEM: std::sync::OnceLock<Semaphore> = std::sync::OnceLock::new();
79 SEM.get_or_init(|| {
80 let n = std::env::var("E2B_CONCURRENCY")
81 .ok()
82 .and_then(|v| v.parse::<usize>().ok())
83 .filter(|&n| n > 0)
84 .unwrap_or(E2B_DEFAULT_CONCURRENCY);
85 tracing::info!("ExecPython: E2B concurrency cap = {}", n);
86 Semaphore::new(n)
87 })
88}
89
90#[derive(Default)]
91pub struct CodeNode;

Callers 1

run_in_e2bFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected