From b46f0130d93a6d53f23de2f79a4815a8197232d7 Mon Sep 17 00:00:00 2001 From: Yuxing Fei Date: Sun, 6 Oct 2024 17:15:55 -0700 Subject: [PATCH] fix(bug): fix the TimeoutError in Python 3.11 and add CI for Python==3.11. The bug is described in #79 --- .github/workflows/ci.yaml | 2 +- .../resource_manager/resource_requester.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 947e43d5..118c4818 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - python-version: ["3.10"] + python-version: ["3.10", "3.11"] services: rabbitmq: image: "rabbitmq:3.9" diff --git a/alab_management/resource_manager/resource_requester.py b/alab_management/resource_manager/resource_requester.py index ff549a80..c996b117 100644 --- a/alab_management/resource_manager/resource_requester.py +++ b/alab_management/resource_manager/resource_requester.py @@ -34,12 +34,18 @@ class RequestCanceledError(Exception): """Request Canceled Error.""" -class CombinedTimeoutError(TimeoutError, concurrent.futures.TimeoutError): - """ - Combined TimeoutError. +# considering concurrent.futures.TimeoutError and TimeoutError becomes the same +# from Python 3.11. We should determine the base class of this exception. +if isinstance(concurrent.futures.TimeoutError, TimeoutError): + CombinedTimeoutError = TimeoutError +else: - If you catch either TimeoutError or concurrent.futures.TimeoutError, this will catch both. - """ + class CombinedTimeoutError(TimeoutError, concurrent.futures.TimeoutError): + """ + Combined TimeoutError. + + If you catch either TimeoutError or concurrent.futures.TimeoutError, this will catch both. + """ class DeviceRequest(BaseModel):