Skip to content

Commit

Permalink
feat(server): print result of a finished submit task (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop authored Jul 4, 2024
1 parent 9c10d0a commit 1576028
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/isolate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,13 @@ def Submit(

self.background_tasks[task_id] = task

def _callback(_):
print(f"Task {task_id} finished")
def _callback(future: futures.Future) -> None:
msg = f"Task {task_id} finished with"
if exc := future.exception():
msg += f" error: {exc!r}"
else:
msg += f" result: {future.result()!r}"
print(msg)
self.background_tasks.pop(task_id, None)

task.future.add_done_callback(_callback)
Expand Down

0 comments on commit 1576028

Please sign in to comment.