]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
make gen.TimeoutError asyncio.TimeoutError 3073/head
authorMin RK <benjaminrk@gmail.com>
Tue, 19 Oct 2021 11:25:46 +0000 (13:25 +0200)
committerMin RK <benjaminrk@gmail.com>
Wed, 20 Oct 2021 11:20:57 +0000 (13:20 +0200)
for more consistent catching of timeouts with other asyncio code

docs/util.rst
tornado/gen.py
tornado/ioloop.py
tornado/test/import_test.py
tornado/util.py

index 0a2012942e3b6b6c6735de2452be9a94260d7126..a4e35ad652085b4764985331275f07fca35cf4b8 100644 (file)
@@ -7,3 +7,15 @@
 
 .. automodule:: tornado.util
     :members:
+
+    .. class:: TimeoutError
+
+        Exception raised by `.gen.with_timeout` and `.IOLoop.run_sync`.
+
+        .. versionchanged:: 5.0
+           Unified ``tornado.gen.TimeoutError`` and
+           ``tornado.ioloop.TimeoutError`` as ``tornado.util.TimeoutError``.
+           Both former names remain as aliases.
+
+        .. versionchanged:: 6.2
+           ``tornado.util.TimeoutError`` is an alias to :py:class:`asyncio.TimeoutError`
index a6370259b391c1bb195bb60bd7895cd2d4528ecc..1946ab91744577a729cacbda71a7c8705e5a96bc 100644 (file)
@@ -606,6 +606,9 @@ def with_timeout(
     .. versionchanged:: 6.0.3
        ``asyncio.CancelledError`` is now always considered "quiet".
 
+    .. versionchanged:: 6.2
+       ``tornado.util.TimeoutError`` is now an alias to ``asyncio.TimeoutError``.
+
     """
     # 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
index 28d86f5049d625a5a5178537c34d8c5b236f25b1..8976c499f75c4a8464e5eb4061ab3b205b1ffabf 100644 (file)
@@ -468,7 +468,7 @@ class IOLoop(Configurable):
 
         The keyword-only argument ``timeout`` may be used to set
         a maximum duration for the function.  If the timeout expires,
-        a `tornado.util.TimeoutError` is raised.
+        a `asyncio.TimeoutError` is raised.
 
         This method is useful to allow asynchronous calls in a
         ``main()`` function::
@@ -485,6 +485,8 @@ class IOLoop(Configurable):
         .. versionchanged:: 5.0
            If a timeout occurs, the ``func`` coroutine will be cancelled.
 
+        .. versionchanged:: 6.2
+           ``tornado.util.TimeoutError`` is now an alias to ``asyncio.TimeoutError``.
         """
         future_cell = [None]  # type: List[Optional[Future]]
 
index 23450fbc6aba4a69aaa03305ebc95a7581545114..dac1f268b0037f6d14d8a45d332ae681de99e041 100644 (file)
@@ -64,3 +64,4 @@ class ImportTest(unittest.TestCase):
 
         self.assertIs(tornado.ioloop.TimeoutError, tornado.util.TimeoutError)
         self.assertIs(tornado.gen.TimeoutError, tornado.util.TimeoutError)
+        self.assertIs(tornado.util.TimeoutError, asyncio.TimeoutError)
index b69500e2ac4cc817b930e945498cc2cadc99a50a..3a3a52f1f22e24c034752dd5764fb291b57b1d24 100644 (file)
@@ -11,6 +11,7 @@ and `.Resolver`.
 """
 
 import array
+import asyncio
 import atexit
 from inspect import getfullargspec
 import os
@@ -63,14 +64,9 @@ except ImportError:
     is_finalizing = _get_emulated_is_finalizing()
 
 
-class TimeoutError(Exception):
-    """Exception raised by `.with_timeout` and `.IOLoop.run_sync`.
-
-    .. versionchanged:: 5.0:
-       Unified ``tornado.gen.TimeoutError`` and
-       ``tornado.ioloop.TimeoutError`` as ``tornado.util.TimeoutError``.
-       Both former names remain as aliases.
-    """
+# versionchanged:: 6.2
+# no longer our own TimeoutError, use standard asyncio class
+TimeoutError = asyncio.TimeoutError
 
 
 class ObjectDict(Dict[str, Any]):