2016-03-08 16:14:02 -08:00
|
|
|
import sys
|
|
|
|
|
2016-03-05 15:11:39 -08:00
|
|
|
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
|
|
|
|
|
2016-03-05 15:11:39 -08:00
|
|
|
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)
|
|
|
|
|
2016-03-05 15:11:39 -08:00
|
|
|
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))
|
2016-03-05 15:11:39 -08:00
|
|
|
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)
|
|
|
|
|
2016-03-05 15:11:39 -08:00
|
|
|
name, args, returnref = worker.wait_for_next_task()
|
|
|
|
print "received args ", args
|
|
|
|
if args == ["hi"]:
|
|
|
|
sys.exit(0)
|
|
|
|
else:
|
|
|
|
sys.exit(1)
|