From: Scott Gasch Date: Sat, 29 Oct 2022 00:28:27 +0000 (-0700) Subject: Fix wrong TimeoutError in catch. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=8ba38a9764d74522530a4a1e95fa85064039fc1c;p=pyutils.git Fix wrong TimeoutError in catch. --- diff --git a/src/pyutils/parallelize/smart_future.py b/src/pyutils/parallelize/smart_future.py index 3661520..8ac05f1 100644 --- a/src/pyutils/parallelize/smart_future.py +++ b/src/pyutils/parallelize/smart_future.py @@ -30,7 +30,7 @@ from pyutils.parallelize.deferred_operand import DeferredOperand logger = logging.getLogger(__name__) -T = TypeVar('T') +T = TypeVar("T") def wait_any( @@ -80,13 +80,13 @@ def wait_any( exception = f.exception() if exception is not None: logger.warning( - 'Future 0x%x raised an unhandled exception and exited.', + "Future 0x%x raised an unhandled exception and exited.", id(f), ) logger.exception(exception) raise exception yield smart_future_by_real_future[f] - except TimeoutError: + except concurrent.futures.TimeoutError: if callback is not None: callback() if callback is not None: @@ -126,7 +126,8 @@ def wait_all( exception = f.exception() if exception is not None: logger.warning( - 'Future 0x%x raised an unhandled exception and exited.', id(f) + "Future 0x%x raised an unhandled exception and exited.", + id(f), ) logger.exception(exception) raise exception @@ -149,7 +150,7 @@ class SmartFuture(DeferredOperand): wrapped_future: a normal Python :class:`concurrent.Future` object that we are wrapping. """ - super().__init__(set(['id', 'wrapped_future', 'get_id', 'is_ready'])) + super().__init__(set(["id", "wrapped_future", "get_id", "is_ready"])) assert isinstance(wrapped_future, fut.Future) self.wrapped_future = wrapped_future self.id = id_generator.get("smart_future_id")