From eb6807085533bccc2fcaee1cf91c3c540ca010f6 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Fri, 24 Jun 2022 15:05:46 +0200 Subject: [PATCH] Make `drop_operator` function optional --- runtime/examples/python-operator/op.py | 3 --- runtime/src/operator/python.rs | 11 ++++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) 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(()) };