Skip to content

Commit

Permalink
Simplify error handling (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickpetrovic authored Oct 3, 2024
1 parent 4ef8eda commit fb3b519
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions sdk/src/beta9/runner/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def main(channel: Channel):

# Start monitoring the task
thread_pool = ThreadPoolExecutor()
monitor_future = thread_pool.submit(
thread_pool.submit(
_monitor_task,
context=context,
stub_id=config.stub_id,
Expand All @@ -169,16 +169,11 @@ def main(channel: Channel):
)

# Invoke the function and handle its result
result = InvokeResult()
try:
result = invoke_function(function_stub, context, task_id)
if result.exception:
raise result.exception
except BaseException:
result = invoke_function(function_stub, context, task_id)
if result.exception:
handle_task_failure(result, gateway_stub, task_id, container_id, container_hostname)
raise
finally:
monitor_future.cancel()
thread_pool.shutdown(wait=False)
raise result.exception

# End the task and send callback
complete_task(
Expand Down

0 comments on commit fb3b519

Please sign in to comment.