6

Is there any way to asynchronously pass Thrift protocol through Tornado web server?

DarkAnthey
  • 167
  • 2
  • 9

3 Answers3

2
twisted:         Generate Twisted-friendly RPC services.
tornado:         Generate code for use with Tornado.

The command is thrift -gen py:tornado -out ./ hello.thrift

lifei
  • 235
  • 2
  • 10
0

Async indeed includes two parts: tornado async response to reqeust, function aysnc communitation with thrift server.

  1. Tornado supports aysnc response. You can refer to Tornado Async HTTP returning results incrementally and Tornado Asynchronous Handler

  2. thrift aysnc communication. You can refer to https://chamibuddhika.wordpress.com/2011/10/02/apache-thrift-quickstart-tutorial/, although using Java, i think it'll helpful.

Community
  • 1
  • 1
elprup
  • 1,960
  • 2
  • 18
  • 32
0

The simplest way to call a blocking function from a coroutine is to use a ThreadPoolExecutor, which returns Futures that are compatible with coroutines:

thread_pool = ThreadPoolExecutor(4)

@gen.coroutine
def call_blocking():
    yield thread_pool.submit(blocking_func, args)

the blocking_func may your thrift function.

Shuguang Yang
  • 370
  • 1
  • 4
  • 12