Skip to content

Commit

Permalink
add support for old style socket timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
CaptainOfHacks committed Dec 23, 2023
1 parent 0e03f6d commit 85781f1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import socket
from concurrent.futures import CancelledError
from typing import List

Expand All @@ -18,7 +19,7 @@ def on_task_done_callback(future):
except CancelledError:
task.update_task_status(TaskStatus.CANCELED)
task.update_exception_message("Task was canceled!")
except TimeoutError as error:
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 Exception as error:
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/backend/task_manager/test_task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_task_manager():
while task_manager.is_active():
time.sleep(1)

assert task_manager.tasks[0].task_metadata.exception_message == "Task took longer than 1 seconds"
assert task_manager.tasks[0].task_metadata.exception_message == "Task took longer than 1.0 seconds"
assert task_manager.tasks[0].get_task_status() == TaskStatus.TIMEOUT

task_manager.delete_all_tasks()
Expand Down

0 comments on commit 85781f1

Please sign in to comment.