Skip to content

Commit 0710ab4

Browse files
committed
Fail task when heartbeat returns server error.
Currently the task is stopped normally. This PR should be merged after #2415 since it will expose IP addresses.
1 parent ff54a17 commit 0710ab4

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

worker/games.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,12 @@ def shorten_hash(match):
10891089
if current_state["task_id"] is None:
10901090
# This task is no longer necessary.
10911091
# Error message has already been printed.
1092-
return False
1092+
error = current_state["last_error"]
1093+
if error is not None:
1094+
current_state["last_error"] = None
1095+
raise WorkerException(error)
1096+
else:
1097+
return False
10931098
try:
10941099
line = q.get_nowait().strip()
10951100
except Empty:

worker/sri.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"__version": 305, "updater.py": "eDDBPKA/vrTCadgtEJFdL06vSoiysF0JhiHKdEnjQv3zS4kfdOAqnco/DJpDWbvh", "worker.py": "Y0kkVAk+3q3+HuWmVqgcPx7/h+CoLyPihLUszUGrvphfzNn55qXwqC+xh0fPz/Zt", "games.py": "uUpIoWu/jB6IoWN4aqSmRvtb7chhVswcFqIiT+G/cKNUWTam8ARxMZARNmTqGQ9p"}
1+
{"__version": 305, "updater.py": "eDDBPKA/vrTCadgtEJFdL06vSoiysF0JhiHKdEnjQv3zS4kfdOAqnco/DJpDWbvh", "worker.py": "ZFcoVOBV7YvMhCunXgX5Cix1Vn6RV/81534N4BSH0e8Eplsln4dNqlcNJb+VnAhK", "games.py": "skc/jkBaVQxQglPbndKYH1gbZo8VOdb1z72oEAxSDPpCAm65F3Ua3RzbqrjkWeXa"}

worker/worker.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ def heartbeat(worker_info, password, remote, current_state):
12051205
# Error message has already been printed.
12061206
current_state["task_id"] = None
12071207
current_state["run"] = None
1208+
current_state["last_error"] = req["error"]
12081209
else:
12091210
print("Heartbeat stopped.")
12101211

@@ -1309,6 +1310,7 @@ def fetch_and_handle_task(
13091310
run, task_id = req["run"], req["task_id"]
13101311
current_state["run"] = run
13111312
current_state["task_id"] = task_id
1313+
current_state["last_error"] = None
13121314

13131315
print(f"Working on task {task_id} from {remote}/tests/view/{run['_id']}.")
13141316
if "sprt" in run["args"]:
@@ -1368,6 +1370,7 @@ def fetch_and_handle_task(
13681370

13691371
current_state["task_id"] = None
13701372
current_state["run"] = None
1373+
current_state["last_error"] = None
13711374

13721375
payload = {
13731376
"password": password,
@@ -1462,6 +1465,7 @@ def worker():
14621465
current_state = {
14631466
"run": None, # the current run
14641467
"task_id": None, # the id of the current task
1468+
"last_error": None, # set in the hearbeat loop
14651469
"alive": True, # controls the main and heartbeat loop
14661470
"last_updated": datetime.now(
14671471
timezone.utc

0 commit comments

Comments
 (0)