ray/test/testrecv.py

38 lines
972 B
Python
Raw Normal View History

2016-03-08 16:14:02 -08:00
import sys
import orchpy.unison as unison
import orchpy.services as services
import orchpy.worker as worker
2016-03-09 11:40:36 -08:00
@worker.distributed([str], [str])
def print_string(string):
print "called print_string with", string
return string
@worker.distributed([int, int], [int, int])
def handle_int(a, b):
return a + 1, b + 1
if __name__ == '__main__':
2016-03-08 16:14:02 -08:00
ip_address = sys.argv[1]
scheduler_port = sys.argv[2]
worker_port = sys.argv[3]
objstore_port = sys.argv[4]
def address(host, port):
return host + ":" + str(port)
worker = worker.Worker()
2016-03-08 16:14:02 -08:00
worker.connect(address(ip_address, scheduler_port), address(ip_address, worker_port), address(ip_address, objstore_port))
worker.start_worker_service()
2016-03-09 11:40:36 -08:00
worker.register_function("print_string", print_string, 0)
worker.register_function("handle_int", handle_int, 0)
name, args, returnref = worker.wait_for_next_task()
print "received args ", args
if args == ["hi"]:
sys.exit(0)
else:
sys.exit(1)