Skip to content

Commit

Permalink
change TimeoutError to OSError old exception
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainOfHacks committed Dec 23, 2023
1 parent 85781f1 commit d233271
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mapping_workbench/backend/task_manager/adapters/task_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import socket
from concurrent.futures import CancelledError
from typing import List

Expand All @@ -19,12 +18,19 @@ def on_task_done_callback(future):
except CancelledError:
task.update_task_status(TaskStatus.CANCELED)
task.update_exception_message("Task was canceled!")
except (socket.timeout, TimeoutError) as error:
task.update_task_status(TaskStatus.TIMEOUT)
task.update_exception_message(f"Task took longer than {error.args[1]} seconds")
except OSError as error:
if len(error.args) > 0:
if error.args[0] == "Task timeout":
task.update_task_status(TaskStatus.TIMEOUT)
task.update_exception_message(f"Task took longer than {task.task_metadata.task_timeout} seconds")
else:
task.update_task_status(TaskStatus.FAILED)
task.update_exception_message(
f"Task raised error: {str(error)}\n{error.__traceback__}, error_type={type(error)}")
except Exception as error:
task.update_task_status(TaskStatus.FAILED)
task.update_exception_message(f"Task raised error: {str(error)}\n{error.__traceback__}")
task.update_exception_message(
f"Task raised error: {str(error)}\n{error.__traceback__}, error_type={type(error)}")


class TaskManager:
Expand Down

0 comments on commit d233271

Please sign in to comment.