[ https://issues.apache.org/jira/browse/THRIFT-5024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17934041#comment-17934041 ]
Asjad edited comment on THRIFT-5024 at 3/27/25 7:23 PM: -------------------------------------------------------- The [Tornado 5.1 docs|https://www.tornadoweb.org/en/branch5.1/gen.html] say that {{@gen.engine}} has been ??Deprecated since version 5.1: This decorator will be removed in 6.0. Use {{[{{coroutine}}|https://www.tornadoweb.org/en/branch5.1/gen.html#tornado.gen.coroutine]}} or {{{{{}async def{}}}}} instead.?? and accordingly, {{@gen.engine}} is missing in the [Tornado 6.0+ docs|https://www.tornadoweb.org/en/branch6.0/gen.html#tornado.gen.coroutine]. So we have two options (as described by the deprecation notice): # Replace {{@gen.engine def}} with {{{}@gen.coroutine def{}}}. The fix is as simple as replacing it on [this line|https://github.com/apache/thrift/blob/3494e1cd087f1d89848275445d92274a8734dbbf/compiler/cpp/src/thrift/generate/t_py_generator.cc#L1463], the only usage. # Replace {{@gen.engine def}} with {{{}async def{}}}. This seems more complicated in terms of adding {{{}async{}}}/{{{}await{}}} everywhere. I prefer #1 as the fix because it's more straightforward, and I've fixed and tested the tutorial this way. I can make a PR. {code:java} diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index 893d6355c..c34bb43bc 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -1460,7 +1460,7 @@ void t_py_generator::generate_service_client(t_service* tservice) { if (gen_tornado_ && extends.empty()) { f_service_ << '\n' << - indent() << "@gen.engine" << '\n' << + indent() << "@gen.coroutine" << '\n' << indent() << "def _start_receiving(self):" << '\n'; indent_up(); indent(f_service_) << "while True:" << '\n';{code} (Note that even with this fix the tutorial still fails with error {{{}AttributeError: 'TTornadoServer' object has no attribute 'io_loop'{}}}. For testing we can work around this by adding {{server.io_loop = None}} after declaring server (in PythonServer.py), but I'm planning on opening a ticket to properly fix this. Edit: Created THRIFT-5857) was (Author: JIRAUSER308968): The [Tornado 5.1 docs|https://www.tornadoweb.org/en/branch5.1/gen.html] say that {{@gen.engine}} has been ??Deprecated since version 5.1: This decorator will be removed in 6.0. Use {{[{{coroutine}}|https://www.tornadoweb.org/en/branch5.1/gen.html#tornado.gen.coroutine]}} or {{{{{}async def{}}}}} instead.?? and accordingly, {{@gen.engine}} is missing in the [Tornado 6.0+ docs|https://www.tornadoweb.org/en/branch6.0/gen.html#tornado.gen.coroutine]. So we have two options (as described by the deprecation notice): # Replace {{@gen.engine def}} with {{{}@gen.coroutine def{}}}. The fix is as simple as replacing it on [this line|https://github.com/apache/thrift/blob/3494e1cd087f1d89848275445d92274a8734dbbf/compiler/cpp/src/thrift/generate/t_py_generator.cc#L1463], the only usage. # Replace {{@gen.engine def}} with {{{}async def{}}}. This seems more complicated in terms of adding {{{}async{}}}/{{{}await{}}} everywhere. I prefer #1 as the fix because it's more straightforward, and I've fixed and tested the tutorial this way. I can make a PR. {code:java} diff --git a/compiler/cpp/src/thrift/generate/t_py_generator.cc b/compiler/cpp/src/thrift/generate/t_py_generator.cc index 893d6355c..c34bb43bc 100644 --- a/compiler/cpp/src/thrift/generate/t_py_generator.cc +++ b/compiler/cpp/src/thrift/generate/t_py_generator.cc @@ -1460,7 +1460,7 @@ void t_py_generator::generate_service_client(t_service* tservice) { if (gen_tornado_ && extends.empty()) { f_service_ << '\n' << - indent() << "@gen.engine" << '\n' << + indent() << "@gen.coroutine" << '\n' << indent() << "def _start_receiving(self):" << '\n'; indent_up(); indent(f_service_) << "while True:" << '\n';{code} (Note that even with this fix the tutorial still fails with error {{{}AttributeError: 'TTornadoServer' object has no attribute 'io_loop'{}}}. For testing we can work around this by adding {{server.io_loop = None}} after declaring server (in PythonServer.py), but I'm planning on opening a ticket to properly fix this. Edit: Created [THRI[link title|http://example.com]FT-5857|http://example.com/]) > tutorial\py.tornado\PythonServer.py failed under Tornado6 > --------------------------------------------------------- > > Key: THRIFT-5024 > URL: https://issues.apache.org/jira/browse/THRIFT-5024 > Project: Thrift > Issue Type: Bug > Components: Python - Compiler > Affects Versions: 0.13.0 > Reporter: Honglei Jiang > Assignee: Jens Geyer > Priority: Major > Fix For: 0.22.0 > > Time Spent: 20m > Remaining Estimate: 0h > > File "E:\PythonLibs\dmaproxy\tests\ThriftAPI\py.tornado\PythonServer.py", > line 28, in <module> > from tutorial import Calculator > File > "E:\PythonLibs\dmaproxy\tests\ThriftAPI\py.tornado\tutorial\Calculator.py", > line 14, in <module> > import shared.SharedService > File > "E:\PythonLibs\dmaproxy\tests\ThriftAPI\py.tornado\shared\SharedService.py", > line 33, in <module> > class Client(Iface): > File > "E:\PythonLibs\dmaproxy\tests\ThriftAPI\py.tornado\shared\SharedService.py", > line 43, in Client > @gen.engine > builtins.AttributeError: module 'tornado.gen' has no attribute 'engine' -- This message was sent by Atlassian Jira (v8.20.10#820010)