From 42ca70b0101fceb964ed52f862186cdb21740bae Mon Sep 17 00:00:00 2001 From: Jacqueline Garrahan Date: Fri, 23 Oct 2020 12:11:33 -0700 Subject: [PATCH] BUG: Fix protocol passing to server --- examples/server.py | 5 ++-- lume_epics/commands/serve_from_template.py | 3 +- lume_epics/epics_server.py | 33 ++++++++++++---------- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/examples/server.py b/examples/server.py index 58c4835..fdb09e0 100644 --- a/examples/server.py +++ b/examples/server.py @@ -5,11 +5,12 @@ with open("examples/files/demo_config.yml", "r") as f: input_variables, output_variables = variables_from_yaml(f) -model = DemoModel(input_variables=input_variables, output_variables=output_variables) prefix = "test" server = Server( - model, + DemoModel, prefix, + model_kwargs={"input_variables": input_variables, "output_variables": output_variables}, + protocols=["pva"] ) # monitor = False does not loop in main thread server.start(monitor=True) \ No newline at end of file diff --git a/lume_epics/commands/serve_from_template.py b/lume_epics/commands/serve_from_template.py index 8f772db..0db52f1 100644 --- a/lume_epics/commands/serve_from_template.py +++ b/lume_epics/commands/serve_from_template.py @@ -24,7 +24,8 @@ def serve_from_template(filename, prefix, serve_ca, serve_pva): server = Server( model_class, prefix, - model_kwargs=model_kwargs + model_kwargs=model_kwargs, + protocols = protocols ) server.start(monitor=True) diff --git a/lume_epics/epics_server.py b/lume_epics/epics_server.py index 20f775b..244a3c0 100644 --- a/lume_epics/epics_server.py +++ b/lume_epics/epics_server.py @@ -113,20 +113,23 @@ def __init__( } ) - self.ca_process = CAServer( - prefix=self.prefix, - input_variables=self.input_variables, - output_variables=self.output_variables, - in_queue=self.in_queue, - out_queue=self.out_queues["ca"] - ) - self.pva_process = PVAServer( - prefix=self.prefix, - input_variables=self.input_variables, - output_variables=self.output_variables, - in_queue=self.in_queue, - out_queue=self.out_queues["pva"] - ) + if "ca" in protocols: + self.ca_process = CAServer( + prefix=self.prefix, + input_variables=self.input_variables, + output_variables=self.output_variables, + in_queue=self.in_queue, + out_queue=self.out_queues["ca"] + ) + + if "pva" in protocols: + self.pva_process = PVAServer( + prefix=self.prefix, + input_variables=self.input_variables, + output_variables=self.output_variables, + in_queue=self.in_queue, + out_queue=self.out_queues["pva"] + ) def run_comm_thread(self, model_class, model_kwargs={}, in_queue: multiprocessing.Queue=None, out_queues: Dict[str, multiprocessing.Queue]=None): @@ -177,7 +180,7 @@ def start(self, monitor: bool = True) -> None: Args: monitor (bool): Indicates whether to run the server in the background or to continually monitor. If monitor = False, the server must be - explicitely stopped using server.stop() + explicitly stopped using server.stop() """ self.comm_thread.start()