pub struct PyGlobalState {Show 33 fields
pub interpreter_id: i64,
pub runtime_root_id: i64,
pub whence: InterpreterWhence,
pub is_main: bool,
pub config: PyConfig,
pub module_defs: BTreeMap<&'static str, &'static PyModuleDef>,
pub frozen: HashMap<&'static str, FrozenModule, RandomState>,
pub stacksize: AtomicCell<usize>,
pub thread_count: AtomicCell<usize>,
pub atexit_funcs: PyMutex<Vec<PyRc<(PyObjectRef, FuncArgs)>>>,
pub codec_registry: CodecsRegistry,
pub struct_format_cache: FormatSpecCache,
pub finalizing: AtomicBool,
pub warnings: WarningsState,
pub override_frozen_modules: AtomicCell<isize>,
pub before_forkers: PyMutex<Vec<PyObjectRef>>,
pub after_forkers_child: PyMutex<Vec<PyObjectRef>>,
pub after_forkers_parent: PyMutex<Vec<PyObjectRef>>,
pub int_max_str_digits: AtomicCell<usize>,
pub switch_interval: AtomicCell<f64>,
pub global_trace_func: PyMutex<Option<PyObjectRef>>,
pub global_profile_func: PyMutex<Option<PyObjectRef>>,
pub type_mutex: PyMutex<()>,
pub monitoring: PyMutex<MonitoringState>,
pub monitoring_events: AtomicCell<u32>,
pub instrumentation_version: AtomicU64,
pub gc: GcInterpreterState,
pub feature_flags: InterpFeatureFlags,
pub own_gil: bool,
pub running_main: AtomicBool,
pub ready: AtomicBool,
pub id_refcount: AtomicI64,
pub require_idref: AtomicBool,
/* private fields */
}Expand description
Per-interpreter shared state (≈ CPython PyInterpreterState).
Not process-global: each Interpreter (main or subinterpreter) owns its own
PyGlobalState. Process-wide pieces live elsewhere (Context::genesis,
GC, the interpreter registry in runtime).
Fields§
§interpreter_id: i64Unique process-global interpreter id (main is MAIN_INTERPRETER_ID).
runtime_root_id: i64Top-level interpreter whose runtime owns this interpreter.
whence: InterpreterWhenceHow this interpreter was created.
is_main: boolTrue for every top-level (non-sub) interpreter, each of which keeps its
own signal and main-thread bookkeeping. Only the first one registered
becomes the process main — see runtime::main_interpreter_id.
config: PyConfig§module_defs: BTreeMap<&'static str, &'static PyModuleDef>§frozen: HashMap<&'static str, FrozenModule, RandomState>§stacksize: AtomicCell<usize>§thread_count: AtomicCell<usize>§atexit_funcs: PyMutex<Vec<PyRc<(PyObjectRef, FuncArgs)>>>Registered atexit callbacks, newest first. Shared ownership so
atexit.unregister can keep the entry it is comparing alive while the
list is unlocked, and still recognize it afterwards by identity.
codec_registry: CodecsRegistry§struct_format_cache: FormatSpecCache§finalizing: AtomicBool§warnings: WarningsState§override_frozen_modules: AtomicCell<isize>§before_forkers: PyMutex<Vec<PyObjectRef>>§after_forkers_child: PyMutex<Vec<PyObjectRef>>§after_forkers_parent: PyMutex<Vec<PyObjectRef>>§int_max_str_digits: AtomicCell<usize>§switch_interval: AtomicCell<f64>§global_trace_func: PyMutex<Option<PyObjectRef>>Global trace function for all threads (set by sys._settraceallthreads)
global_profile_func: PyMutex<Option<PyObjectRef>>Global profile function for all threads (set by sys._setprofileallthreads)
type_mutex: PyMutex<()>Global type mutation/versioning mutex for CPython-style FT type operations.
monitoring: PyMutex<MonitoringState>sys.monitoring state (tool names, events, callbacks)
monitoring_events: AtomicCell<u32>Fast-path mask: OR of all tools’ events. 0 means no monitoring overhead.
instrumentation_version: AtomicU64Incremented on every monitoring state change. Code objects compare their local version against this to decide whether re-instrumentation is needed.
gc: GcInterpreterStateThis interpreter’s garbage collector policy and results.
feature_flags: InterpFeatureFlagsIsolated-interpreter feature flags (PEP 684 / PEP 734 config).
own_gil: boolWhether the interpreter was configured with gil="own".
running_main: AtomicBoolWhether __main__ is currently executing via _interpreters.exec / run_*.
ready: AtomicBoolTrue after initialize() has finished (CPython “ready”).
id_refcount: AtomicI64Optional ID refcount used by _interpreters.create(reqrefs=True).
require_idref: AtomicBoolWhen true, dropping the last ID ref destroys the interpreter.
Implementations§
Source§impl PyGlobalState
impl PyGlobalState
pub fn is_main_interpreter(&self) -> bool
pub fn allow_fork(&self) -> bool
pub fn allow_exec(&self) -> bool
pub fn allow_threads(&self) -> bool
pub fn allow_daemon_threads(&self) -> bool
Sourcepub fn config(&self) -> InterpreterConfig
pub fn config(&self) -> InterpreterConfig
The config this interpreter was created with, rebuilt from the flags it
kept (_PyInterpreterConfig_InitFromState).
Auto Trait Implementations§
impl !Freeze for PyGlobalState
impl !RefUnwindSafe for PyGlobalState
impl !Send for PyGlobalState
impl !Sync for PyGlobalState
impl !UnwindSafe for PyGlobalState
impl Unpin for PyGlobalState
impl UnsafeUnpin for PyGlobalState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> Helper for T
Source§impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
impl<T, U> ImaginaryInto<U> for Twhere
U: ImaginaryFrom<T>,
fn imaginary_into(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more