1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Process-wide tokio runtime, initialized lazily on first use.
//!
//! NEVER initialize at import/module-load time: spawning runtime threads
//! before an application forks (common in Python preload patterns) leaves
//! the child with a dead runtime. Lazy init means a child that never
//! touched the SDK pre-fork gets a fresh runtime on first use.
use Future;
use OnceLock;
use Runtime;
static RUNTIME: = new;
/// Return the process-wide multi-threaded tokio runtime, building it on first
/// call. Safe to call after a fork in a child that never used the SDK pre-fork.
/// Drive an SDK future to completion on the shared internal runtime, for
/// synchronous callers outside any async context.
///
/// Must not be called from within a tokio runtime ("Cannot start a runtime
/// from within a runtime"); an async host should await the `async` API
/// directly instead.
// The sync facade for the PyO3 bridge (with the GIL released) and the CLI. The
// debug assert documents the never-inside-a-runtime invariant of those entry
// points.