Asjad created THRIFT-5857:
-----------------------------
Summary: Remove deprecated Tornado io_loop usage
Key: THRIFT-5857
URL: https://issues.apache.org/jira/browse/THRIFT-5857
Project: Thrift
Issue Type: Bug
Components: Python - Library
Affects Versions: 0.22.0
Environment: Tornado 5+
Definitely for Tornado 6.4.2 that I'm using
Reporter: Asjad
As I mentioned in THRIFT-5024, there's still another issue that's preventing
Thrift from working with newer versions of Tornado. We get this stack trace
once the client is started:
{code:java}
~/thrift$ cd tutorial/py.tornado/
~/thrift/tutorial/py.tornado$ python3 ./PythonServer.py
Starting the server...
Exception in callback functools.partial(<function
TCPServer._handle_connection.<locals>.<lambda> at 0x7fb547e99360>, <Future
finished exception=AttributeError("'TTornadoServer' object has no attribute
'io_loop'")>)
Traceback (most recent call last):
File "/home/asjad/.local/lib/python3.10/site-packages/tornado/ioloop.py",
line 750, in _run_callback
ret = callback()
File "/home/asjad/.local/lib/python3.10/site-packages/tornado/tcpserver.py",
line 387, in <lambda>
gen.convert_yielded(future), lambda f: f.result()
File "/home/asjad/.local/lib/python3.10/site-packages/tornado/gen.py", line
233, in wrapper
yielded = ctx_run(next, result)
File
"/home/asjad/thrift/tutorial/py.tornado/../../lib/py/build/lib.linux-x86_64-3.10/thrift/TTornado.py",
line 168, in handle_stream
io_loop=self.io_loop)
AttributeError: 'TTornadoServer' object has no attribute 'io_loop'{code}
{code:java}
~/thrift$ cd tutorial/py.tornado/
~/thrift/tutorial/py.tornado$ python3 ./PythonClient.py{code}
This bug appeared because {{TTornadoServer}} inherits from Tornado's
{{tcpserver.TCPServer}} and is using its {{self.io_loop}} attribute, which
[Tornado removed in
v5.0|https://github.com/tornadoweb/tornado/blob/ad9652512ff6a7486ca5290b060e7272d1696a37/tornado/tcpserver.py#L120-L122],
[as passing around {{io_loops}} is deprecated in favor of using
{{IOLoop.current()}} to retrieve
it|https://github.com/tornadoweb/tornado/commit/547e0f98d56bb8f22a89c009b6d2b3cf6b802284].
In the PR I also got rid of the io_loop argument for TTornadoStreamTransport as
well, as I doubt anyone is making use of it and it cleans up the code a bit.
Let me know if you still want to keep the argument and I can adjust the PR.
I also touched the `gen.with_timeout` call as that signature also changed to
remove `io_loop`:
([v4.5](https://www.tornadoweb.org/en/branch4.5/gen.html#tornado.gen.with_timeout)
vs
[v5.1](https://www.tornadoweb.org/en/branch5.1/gen.html#tornado.gen.with_timeout)).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)