]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
twisted: Restore the install() function 2653/head
authorBen Darnell <ben@bendarnell.com>
Sun, 5 May 2019 15:50:34 +0000 (11:50 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 5 May 2019 17:12:05 +0000 (13:12 -0400)
This function had more usage than I was aware of and we can preserve
the old behavior by making it an alias for asyncioreactor.install.

Fixes #2636

tornado/platform/twisted.py

index d3eb83b766619943d6c1f1f7c5b20f81be7edc04..0987a84ab74f78d12174fa8d2bc82121356644fe 100644 (file)
@@ -104,6 +104,30 @@ class TwistedResolver(Resolver):
         return result
 
 
+def install() -> None:
+    """Install ``AsyncioSelectorReactor`` as the default Twisted reactor.
+
+    .. deprecated:: 5.1
+
+       This function is provided for backwards compatibility; code
+       that does not require compatibility with older versions of
+       Tornado should use
+       ``twisted.internet.asyncioreactor.install()`` directly.
+
+    .. versionchanged:: 6.0.3
+
+       In Tornado 5.x and before, this function installed a reactor
+       based on the Tornado ``IOLoop``. When that reactor
+       implementation was removed in Tornado 6.0.0, this function was
+       removed as well. It was restored in Tornado 6.0.3 using the
+       ``asyncio`` reactor instead.
+
+    """
+    from twisted.internet.asyncioreactor import install
+
+    install()
+
+
 if hasattr(gen.convert_yielded, "register"):
 
     @gen.convert_yielded.register(Deferred)  # type: ignore