def send_match_to_worker(self, match, workerfile): worker_data = aiweb_tools.worker.Worker_data() worker_data.read(workerfile) filepath = config.matchmaker_path + "match" + config.delimiter + worker_data.uuid + match.short_string() match.set_for_worker(worker_data.uuid) match.write_file(filepath) comms.send_task_worker_ip(filepath, worker_data.ip_addr) comms.delete_file(filepath)
def request_task(self): """ Send a task request to the task server""" print("Requesting task") srcname = "worker-ready" + config.delimiter + (datetime.datetime.now().isoformat()).replace(":", "-") + config.delimiter + self.uuid.hex f = open(srcname, 'w') f.write(self.task_request_content()) f.close() comms.send_task_worker_ip (srcname, config.task_ip) comms.delete_file(srcname)
def send_match_to_worker(self, match, workerfile): try: worker_data = aiweb_tools.worker.Worker_data() worker_data.read(workerfile) filepath = config.matchmaker_path + "match" + config.delimiter + worker_data.uuid + match.short_string() match.set_for_worker(worker_data.uuid) match.write_file(filepath) comms.send_task_worker_ip(filepath, worker_data.ip_addr) comms.delete_file(filepath) except FileNotFoundError: print("WARNING: worker file " + workerfile + " does not exist")
def send_task_to_worker(task, worker_file): """ send task to the worker specified in worker_file """ print("send_task_to_worker") with open(worker_file) as worker_fo: worker_ip = worker_fo.readline().strip() worker_id = worker_fo.readline().strip() print(worker_ip) with open (task, "a") as taskfile: taskfile.write(" " + worker_id) print("id = " + worker_id) comms.send_task_worker_ip(task, worker_ip) comms.delete_file(task)