Skip to content

Commit 2a3e4db

Browse files
committed
THRIFT-5857: Remove deprecated Tornado io_loop usage
1 parent 7cfd018 commit 2a3e4db

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/py/src/TTornado.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import logging
2121
import socket
2222
import struct
23+
import warnings
2324

2425
from .transport.TTransport import TTransportException, TTransportBase, TMemoryBuffer
2526

@@ -66,17 +67,27 @@ def _lock_context(self):
6667
class TTornadoStreamTransport(TTransportBase):
6768
"""a framed, buffered transport over a Tornado stream"""
6869
def __init__(self, host, port, stream=None, io_loop=None):
70+
if io_loop is not None:
71+
warnings.warn(
72+
"The `io_loop` parameter is deprecated and unused. Passing "
73+
"`io_loop` is unnecessary because Tornado now automatically "
74+
"provides the current I/O loop via `IOLoop.current()`. "
75+
"Remove the `io_loop` parameter to ensure compatibility - it "
76+
"will be removed in a future release.",
77+
DeprecationWarning,
78+
stacklevel=2,
79+
)
6980
self.host = host
7081
self.port = port
71-
self.io_loop = io_loop or ioloop.IOLoop.current()
82+
self.io_loop = ioloop.IOLoop.current()
7283
self.__wbuf = BytesIO()
7384
self._read_lock = _Lock()
7485

7586
# servers provide a ready-to-go stream
7687
self.stream = stream
7788

7889
def with_timeout(self, timeout, future):
79-
return gen.with_timeout(timeout, future, self.io_loop)
90+
return gen.with_timeout(timeout, future)
8091

8192
@gen.coroutine
8293
def open(self, timeout=None):
@@ -164,8 +175,7 @@ def __init__(self, processor, iprot_factory, oprot_factory=None,
164175
@gen.coroutine
165176
def handle_stream(self, stream, address):
166177
host, port = address[:2]
167-
trans = TTornadoStreamTransport(host=host, port=port, stream=stream,
168-
io_loop=self.io_loop)
178+
trans = TTornadoStreamTransport(host=host, port=port, stream=stream)
169179
oprot = self._oprot_factory.getProtocol(trans)
170180

171181
try:

0 commit comments

Comments
 (0)