From be6fba6a5ded0f447595644a883f4a9be4b64f88 Mon Sep 17 00:00:00 2001 From: quentin on chickenita Date: Tue, 27 Aug 2024 12:43:54 +0200 Subject: [PATCH] Add possibility to extend end nodes --- pypeman/channels.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/pypeman/channels.py b/pypeman/channels.py index 66ec9c4..69dcd7b 100644 --- a/pypeman/channels.py +++ b/pypeman/channels.py @@ -10,7 +10,6 @@ from pathlib import Path from pypeman import message, msgstore, events -from pypeman.errors import PypemanConfigError from pypeman.helpers.itertools import flatten from pypeman.helpers.sleeper import Sleeper @@ -441,7 +440,6 @@ async def subhandle(self, msg): """ result = await self.process(msg) - if self.next_node: if isinstance(result, types.GeneratorType): gene = result @@ -616,7 +614,7 @@ def add_join_nodes(self, *end_nodes): - SubChannel: no other endnodes will be launched (except final_nodes) """ if self.join_nodes: - raise PypemanConfigError(f"join_nodes already existing for channel {self.name}") + end_nodes = self.join_nodes.extend(end_nodes) self.join_nodes = self._init_end_nodes(*end_nodes) def add_fail_nodes(self, *end_nodes): @@ -626,7 +624,7 @@ def add_fail_nodes(self, *end_nodes): The first node take the entry message of the channel as input """ if self.fail_nodes: - raise PypemanConfigError(f"fail_nodes already existing for channel {self.name}") + end_nodes = self.fail_nodes.extend(end_nodes) self.fail_nodes = self._init_end_nodes(*end_nodes) def add_drop_nodes(self, *end_nodes): @@ -635,7 +633,7 @@ def add_drop_nodes(self, *end_nodes): The first node take the entry message of the channel as input """ if self.drop_nodes: - raise PypemanConfigError(f"drop_nodes already existing for channel {self.name}") + end_nodes = self.drop_nodes.extend(end_nodes) self.drop_nodes = self._init_end_nodes(*end_nodes) def add_reject_nodes(self, *end_nodes): @@ -644,7 +642,7 @@ def add_reject_nodes(self, *end_nodes): The first node take the entry message of the channel as input """ if self.reject_nodes: - raise PypemanConfigError(f"reject_nodes already existing for channel {self.name}") + end_nodes = self.reject_nodes.extend(end_nodes) self.reject_nodes = self._init_end_nodes(*end_nodes) def add_final_nodes(self, *end_nodes): @@ -653,7 +651,7 @@ def add_final_nodes(self, *end_nodes): The first node take the entry message of the channel as input (TODO: ask if it's ok) """ if self.final_nodes: - raise PypemanConfigError(f"final_nodes already existing for channel {self.name}") + end_nodes = self.final_nodes.extend(end_nodes) self.final_nodes = self._init_end_nodes(*end_nodes) # def _callback(self, future):