Source code for msgtransfer2.service_node
"""
Module **sesf.msgtransfer2.service_node** has class ``Node`` that
has the signature of a msgtransfer2 implementation node
and redirects incoming calls to RPC calls to a running msgtransfer2.service
with pyrodaemon `sesf.msgtransfer2.service`.
"""
import Pyro4, argparse
[docs]class Node():
def __init__(self, argv):
# argv == 'model_node num_nodes myid'
p = argparse.ArgumentParser()
p.add_argument("num_nodes", type=int)
p.add_argument("myid", type=int)
args = p.parse_args(argv[1:])
# num_nodes not used; should be 2
self.num_nodes = args.num_nodes
self.myid = args.myid
self.pyroname = 'sesf.msgtransfer2.service'
print('getting', self.pyroname, 'proxies', flush=True)
self.sendproxy = Pyro4.Proxy('PYRONAME:' + self.pyroname)
self.recvproxy = Pyro4.Proxy('PYRONAME:' + self.pyroname)
self.endproxy = Pyro4.Proxy('PYRONAME:' + self.pyroname)
def send(self, msg):
return self.sendproxy.send(self.myid, msg)
def recv(self):
return self.recvproxy.recv(self.myid)
def end(self):
return self.endproxy.end(self.myid)
# end class Msgtransfer2modelwrap