diff --git a/runtime/examples/python-operator/op.py b/runtime/examples/python-operator/op.py index fde0c4e9..aec58419 100644 --- a/runtime/examples/python-operator/op.py +++ b/runtime/examples/python-operator/op.py @@ -1,9 +1,6 @@ class Operator: def __init__(self, counter=0): self.counter = counter - - def drop_operator(self): - print('drop python operator') def on_input(self, id, value, send_output): val_len = len(value) diff --git a/runtime/src/operator/python.rs b/runtime/src/operator/python.rs index 61e99008..90702dde 100644 --- a/runtime/src/operator/python.rs +++ b/runtime/src/operator/python.rs @@ -68,9 +68,14 @@ pub fn spawn( .wrap_err("on_input failed")?; } - operator - .call_method0("drop_operator") - .wrap_err("drop_operator failed")?; + if operator + .hasattr("drop_operator") + .wrap_err("failed to look for drop_operator")? + { + operator + .call_method0("drop_operator") + .wrap_err("drop_operator failed")?; + } Result::<_, eyre::Report>::Ok(()) };