Skip to content

Commit

Permalink
Check for errors when submitting builds
Browse files Browse the repository at this point in the history
  • Loading branch information
manics committed Jul 30, 2022
1 parent 0fa35a0 commit c809aca
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions binderhub/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,25 @@ async def get(self, provider_prefix, _unescaped_spec):
)

with BUILDS_INPROGRESS.track_inprogress():
done = False
failed = False

def _check_result(future):
nonlocal done
nonlocal failed
try:
r = future.result()
app_log.debug("task completed: %s", r)
except Exception:
app_log.error("task failed: %s", exc_info=True)
done = True
failed = True

build_starttime = time.perf_counter()
pool = self.settings["build_pool"]
# Start building
submit_future = pool.submit(build.submit)
# TODO: hook up actual error handling when this fails
submit_future.add_done_callback(_check_result)
IOLoop.current().add_callback(lambda: submit_future)

log_future = None
Expand All @@ -464,8 +478,6 @@ async def get(self, provider_prefix, _unescaped_spec):
}
)

done = False
failed = False
while not done:
progress = await q.get()

Expand All @@ -486,6 +498,7 @@ async def get(self, provider_prefix, _unescaped_spec):
# start capturing build logs once the pod is running
if log_future is None:
log_future = pool.submit(build.stream_logs)
log_future.add_done_callback(_check_result)
continue
elif progress.payload == ProgressEvent.BuildStatus.COMPLETED:
# Do nothing, is ok!
Expand Down

0 comments on commit c809aca

Please sign in to comment.