pub struct PyShared { /* private fields */ }Expand description
Awaitable handle to a spawned background Tokio task.
Shared is returned by PythonTask.spawn() /
spawn_abortable(). It carries a watch receiver that is
fulfilled exactly once with the task’s PyResult<Py<PyAny>>.
Usage:
await sharedinside thePythonTask.from_coroutine(...)world, orshared.block_on()to wait synchronously.
If abort is true (from spawn_abortable()), dropping this
object aborts the underlying Tokio task via its JoinHandle.
Implementations§
Sourcepub fn block_on(slf: PyRef<'_, PyShared>, py: Python<'_>) -> PyResult<Py<PyAny>>
pub fn block_on(slf: PyRef<'_, PyShared>, py: Python<'_>) -> PyResult<Py<PyAny>>
Wait synchronously for this Shared to resolve.
This blocks the calling Python thread until the underlying
background task has published its result into the watch
channel, then returns that Py<PyAny> (or raises the stored
Python exception).
If the value is already available, returns immediately without
blocking. This is important for cases where block_on is called
from within a tokio runtime (e.g., during unpickling on a worker
thread) - we can’t call runtime.block_on() from within a runtime.
Trait Implementations§
This prevents abandoned background work from running forever when no receivers remain. We guard against panics during interpreter shutdown / runtime teardown.
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Awaitable handle to a spawned background Tokio task.
///
/// `Shared` is returned by `PythonTask.spawn()` /
/// `spawn_abortable()`. It carries a `watch` receiver that is
/// fulfilled exactly once with the task's `PyResult<Py<PyAny>>`.
///
/// Usage:
/// - `await shared` inside the `PythonTask.from_coroutine(...)`
/// world, or
/// - `shared.block_on()` to wait synchronously.
///
/// If `abort` is true (from `spawn_abortable()`), dropping this
/// object aborts the underlying Tokio task via its `JoinHandle`.
const RAW_DOC: &'static CStr = /// Awaitable handle to a spawned background Tokio task. /// /// `Shared` is returned by `PythonTask.spawn()` / /// `spawn_abortable()`. It carries a `watch` receiver that is /// fulfilled exactly once with the task's `PyResult<Py<PyAny>>`. /// /// Usage: /// - `await shared` inside the `PythonTask.from_coroutine(...)` /// world, or /// - `shared.block_on()` to wait synchronously. /// /// If `abort` is true (from `spawn_abortable()`), dropping this /// object aborts the underlying Tokio task via its `JoinHandle`.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<PyShared>
type ThreadChecker = SendablePyClass<PyShared>
type Inventory = Pyo3MethodsInventoryForPyShared
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.Auto Trait Implementations§
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoPyObjectBox for Twhere
T: for<'py> IntoPyObject<'py> + Send,
impl<T> IntoPyObjectBox for Twhere
T: for<'py> IntoPyObject<'py> + Send,
fn into_py_object(self: Box<T>, py: Python<'_>) -> Result<Py<PyAny>, PyErr>
§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].