From 15760289c8c1b00c60561d5bc2ced126baa018a3 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Fri, 5 Jul 2024 00:20:04 +0300 Subject: [PATCH] feat(server): print result of a finished submit task (#148) --- src/isolate/server/server.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/isolate/server/server.py b/src/isolate/server/server.py index 1a89470..7b9b4fd 100644 --- a/src/isolate/server/server.py +++ b/src/isolate/server/server.py @@ -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)