Skip to content

Commit d1dd772

Browse files
committed
Right asyncio loop syntax (following #2237)
1 parent 47f8e25 commit d1dd772

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

compute_worker/compute_worker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,10 +1226,12 @@ def start(self):
12261226
task_results = [] # will store results/exceptions from gather
12271227
signal.signal(signal.SIGALRM, alarm_handler)
12281228
signal.alarm(self.execution_time_limit)
1229+
12291230
try:
12301231
# run tasks
12311232
# keep what gather returned so we can detect async errors later
12321233
task_results = loop.run_until_complete(gathered_tasks) or []
1234+
12331235
except ExecutionTimeLimitExceeded:
12341236
error_message = f"Execution Time Limit exceeded. Limit was {self.execution_time_limit} seconds"
12351237
logger.error(error_message)
@@ -1263,7 +1265,10 @@ def start(self):
12631265
# Send error through web socket to the frontend
12641266
asyncio.run(self._send_data_through_socket(error_message))
12651267
raise SubmissionException(error_message)
1268+
12661269
finally:
1270+
signal.alarm(0)
1271+
asyncio.set_event_loop(None)
12671272
loop.close()
12681273
self.watch = False
12691274
for kind, logs in self.logs.items():
@@ -1332,6 +1337,7 @@ def start(self):
13321337
# Raise so upstream marks failed immediately
13331338
raise SubmissionException("Child task failed or non-zero return code")
13341339
self._update_status(STATUS_FINISHED)
1340+
13351341
else:
13361342
self._update_status(STATUS_SCORING)
13371343

0 commit comments

Comments
 (0)