THRIFT-5857: Remove deprecated Tornado io_loop usage
Client: py
Patch: Asjad Syed
This closes #3117
diff --git a/lib/py/src/TTornado.py b/lib/py/src/TTornado.py
index c409e09..0f741c5 100644
--- a/lib/py/src/TTornado.py
+++ b/lib/py/src/TTornado.py
@@ -20,6 +20,7 @@
import logging
import socket
import struct
+import warnings
from .transport.TTransport import TTransportException, TTransportBase, TMemoryBuffer
@@ -66,9 +67,19 @@
class TTornadoStreamTransport(TTransportBase):
"""a framed, buffered transport over a Tornado stream"""
def __init__(self, host, port, stream=None, io_loop=None):
+ if io_loop is not None:
+ warnings.warn(
+ "The `io_loop` parameter is deprecated and unused. Passing "
+ "`io_loop` is unnecessary because Tornado now automatically "
+ "provides the current I/O loop via `IOLoop.current()`. "
+ "Remove the `io_loop` parameter to ensure compatibility - it "
+ "will be removed in a future release.",
+ DeprecationWarning,
+ stacklevel=2,
+ )
self.host = host
self.port = port
- self.io_loop = io_loop or ioloop.IOLoop.current()
+ self.io_loop = ioloop.IOLoop.current()
self.__wbuf = BytesIO()
self._read_lock = _Lock()
@@ -76,7 +87,7 @@
self.stream = stream
def with_timeout(self, timeout, future):
- return gen.with_timeout(timeout, future, self.io_loop)
+ return gen.with_timeout(timeout, future)
@gen.coroutine
def open(self, timeout=None):
@@ -164,8 +175,7 @@
@gen.coroutine
def handle_stream(self, stream, address):
host, port = address[:2]
- trans = TTornadoStreamTransport(host=host, port=port, stream=stream,
- io_loop=self.io_loop)
+ trans = TTornadoStreamTransport(host=host, port=port, stream=stream)
oprot = self._oprot_factory.getProtocol(trans)
try: