mirror of
https://github.com/QingdaoU/JudgeServer.git
synced 2024-12-28 04:51:44 +00:00
log heartbeat response
This commit is contained in:
parent
8af9bac471
commit
8c2d30547c
@ -16,13 +16,20 @@ class JudgeService(object):
|
||||
|
||||
def _request(self, data):
|
||||
try:
|
||||
r = requests.post(self.backend_url, json=data,
|
||||
headers={"X-JUDGE-SERVER-TOKEN": token}, timeout=5).json()
|
||||
resp = requests.post(self.backend_url, json=data,
|
||||
headers={"X-JUDGE-SERVER-TOKEN": token,
|
||||
"Content-Type": "application/json"}, timeout=5).text
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
raise JudgeServiceError(e.message)
|
||||
if r["error"]:
|
||||
raise JudgeServiceError(r["data"])
|
||||
raise JudgeServiceError("Heartbeat request failed")
|
||||
try:
|
||||
r = json.loads(resp)
|
||||
if r["error"]:
|
||||
raise JudgeServiceError(r["data"])
|
||||
except Exception as e:
|
||||
logger.exception("Heartbeat failed, response is {}".format(resp))
|
||||
raise JudgeServiceError("Invalid heartbeat response")
|
||||
|
||||
|
||||
def heartbeat(self):
|
||||
data = server_info()
|
||||
|
Loading…
Reference in New Issue
Block a user