Skip to content

Commit 4ce6dc1

Browse files
authored
Merge pull request #1517 from manics/build-submit-check-errors
Check for low-level errors when submitting builds
2 parents b78cac3 + 72e1852 commit 4ce6dc1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

binderhub/builder.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,26 @@ async def get(self, provider_prefix, _unescaped_spec):
447447
)
448448

449449
with BUILDS_INPROGRESS.track_inprogress():
450+
done = False
451+
failed = False
452+
453+
def _check_result(future):
454+
nonlocal done
455+
nonlocal failed
456+
try:
457+
r = future.result()
458+
app_log.debug("task completed: %s", r)
459+
except Exception:
460+
app_log.error("task failed", exc_info=True)
461+
done = True
462+
failed = True
463+
# TODO: Propagate error to front-end
464+
450465
build_starttime = time.perf_counter()
451466
pool = self.settings["build_pool"]
452467
# Start building
453468
submit_future = pool.submit(build.submit)
454-
# TODO: hook up actual error handling when this fails
469+
submit_future.add_done_callback(_check_result)
455470
IOLoop.current().add_callback(lambda: submit_future)
456471

457472
log_future = None
@@ -464,8 +479,6 @@ async def get(self, provider_prefix, _unescaped_spec):
464479
}
465480
)
466481

467-
done = False
468-
failed = False
469482
while not done:
470483
progress = await q.get()
471484

@@ -486,6 +499,7 @@ async def get(self, provider_prefix, _unescaped_spec):
486499
# start capturing build logs once the pod is running
487500
if log_future is None:
488501
log_future = pool.submit(build.stream_logs)
502+
log_future.add_done_callback(_check_result)
489503
continue
490504
elif progress.payload == ProgressEvent.BuildStatus.COMPLETED:
491505
# Do nothing, is ok!

0 commit comments

Comments
 (0)