]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
gen.with_timeout: Don't log CancelledError after timeout
authorPetr Viktorin <encukou@gmail.com>
Wed, 19 Jun 2019 16:09:17 +0000 (18:09 +0200)
committerPetr Viktorin <encukou@gmail.com>
Wed, 19 Jun 2019 16:13:50 +0000 (18:13 +0200)
See also: commit a237a995a1d54ad6e07c1ecdf5103ff8f45073b5

tornado/gen.py

index 51f2a4f0388a21edbb37d9d4ba8fe77fb55de025..33cc887e5220e51d3547ddec562f26127c658515 100644 (file)
@@ -557,8 +557,9 @@ def with_timeout(
     an absolute time relative to `.IOLoop.time`)
 
     If the wrapped `.Future` fails after it has timed out, the exception
-    will be logged unless it is of a type contained in ``quiet_exceptions``
-    (which may be an exception type or a sequence of types).
+    will be logged unless it is either of a type contained in
+    ``quiet_exceptions`` (which may be an exception type or a sequence of
+    types), or a `CancelledError`.
 
     The wrapped `.Future` is not canceled when the timeout expires,
     permitting it to be reused. `asyncio.wait_for` is similar to this
@@ -573,6 +574,9 @@ def with_timeout(
     .. versionchanged:: 4.4
        Added support for yieldable objects other than `.Future`.
 
+    .. versionchanged:: 6.1
+       Do not log CancelledError after timeout.
+
     """
     # It's tempting to optimize this by cancelling the input future on timeout
     # instead of creating a new one, but A) we can't know if we are the only
@@ -587,6 +591,8 @@ def with_timeout(
     def error_callback(future: Future) -> None:
         try:
             future.result()
+        except asyncio.CancelledError:
+            pass
         except Exception as e:
             if not isinstance(e, quiet_exceptions):
                 app_log.error(