Commit a350ed9a authored by Kento HASEGAWA's avatar Kento HASEGAWA

Use req_id to identify the processing question

parent fa33ab65
......@@ -59,6 +59,7 @@ def load_questions():
"queue": Queue(),
"board_size": board_size,
"line_num": line_num,
"last_req": None,
"answers": [],
}
......@@ -112,18 +113,17 @@ def post():
global questions
global app_args
_client = request.form["client"]
_qname = request.form["qname"]
_answer = request.form["answer"]
_cputime = request.form["cputime"]
receive_time = datetime.datetime.now()
receive_time_str = receive_time.strftime("%Y%m%d%H%M%S")
dat = {
"client": _client,
"req_id": request.form['req_id'],
"client": request.form['client'],
"answer": _answer,
"cputime": _cputime,
"cputime": request.form['cputime'],
"timestamp": receive_time.strftime("%Y/%m/%d %H:%M:%S")
}
......@@ -218,23 +218,26 @@ def solve_questions(qname, qstr):
global clients
global questions
global current_seed
global app_args
def worker(host, qname, qstr, qseed, request_time):
def worker(host, qname, qstr, qseed, req_id):
_url = "http://{}/start".format(host)
try:
r = requests.post(_url, data={"client": host, "qname": qname, "question": qstr, "qseed": qseed, "request_time": request_time})
r = requests.post(_url, data={"client": host, "qname": qname, "question": qstr, "qseed": qseed, "req_id": req_id})
client_res = json.loads(r.text)
except Exception as e:
sys.stderr.write(str(e) + "\n")
threads = []
request_time = time.time()
# 時刻をリクエストIDとして設定
req_id = time.time()
questions[qname]['last_req'] = req_id
for c in clients:
# 問題はSolverに送る
if c[1] == 'Solver':
client_addr = c[0]
_th = threading.Thread(name=client_addr, target=worker, args=(client_addr, qname, qstr, current_seed, request_time))
_th = threading.Thread(name=client_addr, target=worker, args=(client_addr, qname, qstr, current_seed, req_id))
_th.start()
threads.append(_th)
current_seed += 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment