Skip to content

Commit

Permalink
Merge pull request #49 from jacquelinegarrahan/server-cleanup
Browse files Browse the repository at this point in the history
BUG: Fix protocol passing to server
  • Loading branch information
jacquelinegarrahan authored Oct 26, 2020
2 parents c88f92b + 42ca70b commit c029d4d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
5 changes: 3 additions & 2 deletions examples/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion lume_epics/commands/serve_from_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 18 additions & 15 deletions lume_epics/epics_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit c029d4d

Please sign in to comment.