From 97c2dabdd7e371efee4b54726c7bab4e935fd9f5 Mon Sep 17 00:00:00 2001 From: haixuanTao Date: Mon, 29 Apr 2024 20:27:03 +0200 Subject: [PATCH] reintroduce `DoraStatus` --- apis/python/node/dora/__init__.py | 13 +++++++++++++ binaries/runtime/src/operator/python.rs | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apis/python/node/dora/__init__.py b/apis/python/node/dora/__init__.py index e145cc22..58e7778d 100644 --- a/apis/python/node/dora/__init__.py +++ b/apis/python/node/dora/__init__.py @@ -26,3 +26,16 @@ from .dora import ( Ros2Durability, Ros2Liveliness, ) + + +class DoraStatus(Enum): + """Dora status to indicate if operator `on_input` loop + should be stopped. + Args: + Enum (u8): Status signaling to dora operator to + stop or continue the operator. + """ + + CONTINUE = 0 + STOP = 1 + STOP_ALL = 2 diff --git a/binaries/runtime/src/operator/python.rs b/binaries/runtime/src/operator/python.rs index fefc92a4..8ebbbfc2 100644 --- a/binaries/runtime/src/operator/python.rs +++ b/binaries/runtime/src/operator/python.rs @@ -224,9 +224,8 @@ pub fn run( .map_err(traceback); match status_enum { Ok(status_enum) => { - let status_val = - Python::with_gil(|py| status_enum.call_method0(py, "value")) - .wrap_err("on_event must have enum return value")?; + let status_val = Python::with_gil(|py| status_enum.getattr(py, "value")) + .wrap_err("on_event must have enum return value")?; Python::with_gil(|py| status_val.extract(py)) .wrap_err("on_event has invalid return value") }