pub struct PyHandle { /* private fields */ }Expand description
The observe-only handle to a background Tokio task or Python-owned operation.
Exposed to Python as
monarch._rust_bindings.monarch_hyperactor.handle.Handle. HDL-11: Python
cannot construct one directly. Internal Python may obtain one only from the
private _new_handle_pair() factory together with its sole producer.
Implementations§
Source§impl PyHandle
impl PyHandle
Sourcepub fn from_value(value: Py<PyAny>) -> PyResult<Self>
pub fn from_value(value: Py<PyAny>) -> PyResult<Self>
Construct an already-complete Handle from value without spawning a
producer task (HDL-15).
Rust-only and outside #[pymethods], so making this method public does
not make Handle directly constructible from Python (HDL-11).
Sourcepub fn wait_future(
&self,
) -> impl Future<Output = PyResult<Py<PyAny>>> + Send + 'static + use<>
pub fn wait_future( &self, ) -> impl Future<Output = PyResult<Py<PyAny>>> + Send + 'static + use<>
Return an owned, non-consuming Rust observer for this Handle’s value (HDL-14).
The returned future owns a cloned watch receiver, so it borrows nothing
from self, survives the PyHandle being dropped, and can coexist with
any number of other observers.
Sourcepub fn spawn<F, T>(fut: F) -> Self
pub fn spawn<F, T>(fut: F) -> Self
Eagerly drive a Rust future to completion and return an observe-only
Handle over its result (HDL-13).
The producer spawns immediately on the shared Tokio runtime; the returned
Handle observes already-running work rather than starting it lazily on
first observation. On completion the terminal PyResult<T> is converted
to Py<PyAny> under monarch_with_gil and published exactly once through
the shared send_result helper (HDL-1/HDL-2). The core carries
abort_on_drop: None, so dropping the Handle never cancels the producer
(HDL-4). Rust-only and outside #[pymethods], so Python still cannot mint
a core (HDL-11).
Sourcepub fn wait_completion(
&self,
) -> impl Future<Output = PyResult<()>> + Send + 'static + use<>
pub fn wait_completion( &self, ) -> impl Future<Output = PyResult<()>> + Send + 'static + use<>
Observe whether this handle completed successfully, projecting the terminal
value to PyResult<()> (HDL-13).
Returns an owned Send + 'static future over a cloned receiver (HDL-9),
so multiple Rust callers can observe the same terminal state and dropping
the Handle after taking an observer does not abort the producer (HDL-4).
The ready-success fast path touches neither the GIL nor the Python value
(a discriminant-only read, HDL-3); only the error path clones the stored
PyErr. This is the readiness surface for callers that need only the
success/error discriminant, not the value.
Trait Implementations§
impl DerefToPyAny for PyHandle
impl ExtractPyClassWithClone for PyHandle
Source§impl<'py> IntoPyObject<'py> for PyHandle
impl<'py> IntoPyObject<'py> for PyHandle
Source§impl PyClassImpl for PyHandle
impl PyClassImpl for PyHandle
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 = /// The observe-only handle to a background Tokio task or Python-owned operation.
///
/// Exposed to Python as
/// `monarch._rust_bindings.monarch_hyperactor.handle.Handle`. HDL-11: Python
/// cannot construct one directly. Internal Python may obtain one only from the
/// private `_new_handle_pair()` factory together with its sole producer.
const RAW_DOC: &'static CStr = /// The observe-only handle to a background Tokio task or Python-owned operation. /// /// Exposed to Python as /// `monarch._rust_bindings.monarch_hyperactor.handle.Handle`. HDL-11: Python /// cannot construct one directly. Internal Python may obtain one only from the /// private `_new_handle_pair()` factory together with its sole producer.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<PyHandle>
type ThreadChecker = SendablePyClass<PyHandle>
type Inventory = Pyo3MethodsInventoryForPyHandle
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§impl PyTypeInfo for PyHandle
impl PyTypeInfo for PyHandle
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§
impl !RefUnwindSafe for PyHandle
impl !UnwindSafe for PyHandle
impl Freeze for PyHandle
impl Send for PyHandle
impl Sync for PyHandle
impl Unpin for PyHandle
impl UnsafeUnpin for PyHandle
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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>
§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].impl<M> Message for M
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
Use ::classinfo_object() instead and format the type name at runtime. Note that using built-in cast features is often better than manual PyTypeCheck usage.
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more