Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
server_addr = ('localhost', 9090)
class UsageError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
if __name__ == '__main__':
if len(sys.argv) != 4:
raise UsageError("Usage: ")
# client code - attach to the server and send a message
client = ipc.HTTPTransceiver(server_addr[0], server_addr[1])
requestor = ipc.Requestor(PROTOCOL, client)
# fill in the Message record and send it
message = dict()
message['to'] = sys.argv[1]
message['from'] = sys.argv[2]
message['body'] = sys.argv[3]
params = dict()
params['message'] = message
print("Result: " + requestor.request('send', params))
# cleanup
client.close()
def send_message(uri, proto, msg, datum):
url_obj = urlparse.urlparse(uri)
client = ipc.HTTPTransceiver(url_obj.hostname, url_obj.port)
proto_json = file(proto, 'r').read()
requestor = ipc.Requestor(protocol.parse(proto_json), client)
print(requestor.request(msg, datum))
import avro.protocol as protocol
PROTOCOL = protocol.parse(open("../resources/main/demo.avpr").read())
server_addr = ('localhost', 9999)
class UsageError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
if __name__ == '__main__':
# client code - attach to the server and send a message
client = ipc.HTTPTransceiver(server_addr[0], server_addr[1])
req = ipc.Requestor(PROTOCOL, client)
params = {"key": "helloworld", "value": "1", "ttl": 1}
print "memory_setString Result: " , req.request('memory_setString', params)
params = {"key": "helloworld"}
print "memory_getString Result: " , req.request('memory_getString', params)
params = {"key": "helloworld", "ttl": 100}
print "cat_mgetstring Result: " , req.request('trace_msg', params)
lz = []
ts = time.time() * 1000
params = {"key": "helloworld"}
for i in xrange(100):
ss = req.request('memory_getString', params)
# print ss
Send data to other devices. The data packet contains data and models name.
Ip address of next device pop from Queue of a ip list.
Args:
X: numpy array
name: next device models name
tag: mark the current layer label
"""
node = Node.create()
queue = node.ip[name]
address = queue.get()
# initializer use port 9999 to receive data
port = 9999 if name == 'initial' else 12345
client = ipc.HTTPTransceiver(address, port)
requestor = ipc.Requestor(PROTOCOL, client)
node.name = name
data = dict()
data['input'] = X.tostring()
data['next'] = name
data['tag'] = tag
node.log('finish assembly')
start = time.time()
requestor.request('forward', data)
end = time.time()
node.timer(end - start)
node.log('node gets request back')
client.close()
queue.put(address)
def send_message(uri, proto, msg, datum):
url_obj = urllib.parse.urlparse(uri)
client = ipc.HTTPTransceiver(url_obj.hostname, url_obj.port)
proto_json = file(proto, 'r').read()
requestor = ipc.Requestor(protocol.Parse(proto_json), client)
print(requestor.request(msg, datum))
def request(self,*args,**param):
transciever=ipc.HTTPTransceiver(self.server,self.port)
requestor=ipc.Requestor(self.protocol, transciever)
return requestor.request(*args,**param)
Send data to other devices. The data packet contains data and models name.
Ip address of next device pop from Queue of a ip list.
Args:
X: numpy array
name: next device models name
tag: mark the current layer label
"""
node = Node.create()
queue = node.ip[name]
address = queue.get()
# initializer use port 9999 to receive data
port = 9999 if name == 'initial' else 12345
client = ipc.HTTPTransceiver(address, port)
requestor = ipc.Requestor(PROTOCOL, client)
node.name = name
data = dict()
data['input'] = X.tostring()
data['next'] = name
data['tag'] = tag
node.log('finish assembly')
start = time.time()
requestor.request('forward', data)
end = time.time()
node.timer(end - start)
node.log('node gets request back')
client.close()
queue.put(address)
Send data to other devices. The data packet contains data and models name.
Ip address of next device pop from Queue of a ip list.
Args:
X: numpy array
name: next device models name
tag: mark the current layer label
"""
node = Node.create()
queue = node.ip[name]
address = queue.get()
# initializer use port 9999 to receive data
port = 9999 if name == 'initial' else 12345
client = ipc.HTTPTransceiver(address, port)
requestor = ipc.Requestor(PROTOCOL, client)
node.name = name
data = dict()
data['input'] = X.tostring()
data['next'] = name
data['tag'] = tag
node.log('finish assembly')
start = time.time()
requestor.request('forward', data)
end = time.time()
node.timer(end - start)
node.log('node gets request back')
client.close()
queue.put(address)