All Projects → Thriftpy → Gunicorn_thrift

Thriftpy / Gunicorn_thrift

Licence: mit
Thrift app and worker for gunicorn!

Programming Languages

python
139335 projects - #7 most used programming language

Labels

Projects that are alternatives of or similar to Gunicorn thrift

Tchannel
network multiplexing and framing protocol for RPC
Stars: ✭ 1,122 (+481.35%)
Mutual labels:  thrift
Line Instant Messenger Protocol
It is work of Matti Virkkunen, link to http://altrepo.eu/git/line-protocol.git for latest update.
Stars: ✭ 96 (-50.26%)
Mutual labels:  thrift
Thrift Missing Guide
Thrift: The Missing Guide
Stars: ✭ 148 (-23.32%)
Mutual labels:  thrift
Hs2client
C++ native client for Impala and Hive, with Python / pandas bindings
Stars: ✭ 69 (-64.25%)
Mutual labels:  thrift
Springboot Thrift Etcd Ribbon
基于springboot的thrift的rpc, 服务发现基于etcd,路由基于ribbon
Stars: ✭ 75 (-61.14%)
Mutual labels:  thrift
Php Thrift Sql
A PHP library for connecting to Hive or Impala over Thrift
Stars: ✭ 107 (-44.56%)
Mutual labels:  thrift
Thrift Connection Pool
Apache Thrift客户端连接池(client connection pool)
Stars: ✭ 59 (-69.43%)
Mutual labels:  thrift
Elixir Thrift
A Pure Elixir Thrift Implementation
Stars: ✭ 182 (-5.7%)
Mutual labels:  thrift
Evernote Thrift
Thrift IDL files for the Evernote Cloud API
Stars: ✭ 94 (-51.3%)
Mutual labels:  thrift
Herringbone
Tools for working with parquet, impala, and hive
Stars: ✭ 134 (-30.57%)
Mutual labels:  thrift
Andl
Andl is A New Database Language
Stars: ✭ 71 (-63.21%)
Mutual labels:  thrift
Thrift connector
Clients of thrift, utilizing connection pools
Stars: ✭ 74 (-61.66%)
Mutual labels:  thrift
Frugal
Thrift improved
Stars: ✭ 113 (-41.45%)
Mutual labels:  thrift
Thriftpy
Thriftpy has been deprecated, please migrate to https://github.com/Thriftpy/thriftpy2
Stars: ✭ 1,156 (+498.96%)
Mutual labels:  thrift
Spring Thrift Starter
Set of cool annotations that helps you building Thrift applications with Spring Boot
Stars: ✭ 151 (-21.76%)
Mutual labels:  thrift
Nettythrift
Thrift on Netty, support TCP/HTTP/WebSocket at same port. support multiple Protocols at same time. multil Simple Clients with Connection Pool.
Stars: ✭ 60 (-68.91%)
Mutual labels:  thrift
Dapeng Soa
A lightweight, high performance micro-service framework
Stars: ✭ 101 (-47.67%)
Mutual labels:  thrift
Thrift Tools
thrift-tools is a library and a set of tools to introspect Apache Thrift traffic.
Stars: ✭ 189 (-2.07%)
Mutual labels:  thrift
Finatra
Fast, testable, Scala services built on TwitterServer and Finagle
Stars: ✭ 2,126 (+1001.55%)
Mutual labels:  thrift
Aeraki
Manage any layer 7 traffic in Istio Service Mesh.
Stars: ✭ 119 (-38.34%)
Mutual labels:  thrift

gunicorn_thrift

Build Status Coverage Status

Thrift app and worker for gunicorn! Hence, a multi-process python thrift server!

Why?

  • graceful reload/shutdown.
  • manage worker number at runtime.
  • and everything else gunicorn has to offer.

Supported Platforms

  • Python 2.7, all worker classes
  • Python 3.4+, thriftpy_sync and thriftpy_gevent worker classes (code generated using the Thrift toolkit is not supported on Python 3)

Examples

Using thrift

  1. Generate thrift files:

    % thrift --out tests/pingpong_sdk --gen py:new_style,utf8strings tests/pingpong.thrift
    
  2. Write thrift app.

    #! /usr/bin/env python
    # tests/app.py
    # -*- coding: utf-8 -*-
    
    from pingpong_sdk.pingpong import PingService
    
    class PingpongServer(object):
        def ping(self):
            if os.environ.get('about_to_shutdown') == '1':
                raise PingService.AboutToShutDownException
            return "pong"
    
    app = PingService.Processor(PingpongServer())
    
  3. Fire up app.

    % gunicorn_thrift tests.app:app -k thrift_sync
    % gunicorn_thrift tests.app:app -k thrift_gevent
    

Using thriftpy2

  1. Write thrift app.

    #! /usr/bin/env python
    # tests/app.py
    # -*- coding: utf-8 -*-
    
    import thriftpy2
    from thriftpy2.thrift import TProcessor
    
    class PingPongDispatcher(object):
        def ping(self):
            return "pong"
    
    pingpong_thrift = thriftpy2.load("pingpong.thrift")
    app = TProcessor(pingpong_thrift.PingService, PingPongDispatcher())
    
  2. Fire up app.

    % gunicorn_thrift tests.thriftpy_app:app -k thriftpy_sync \
      --thrift-protocol-factory \
        thriftpy2.protocol:TCyBinaryProtocolFactory \
      --thrift-transport-factory \
        thriftpy2.transport:TCyBufferedTransportFactory
    

Configs

Workers

Parameter: -k, --worker-class Config file: worker_class Default 2.7: thrift_sync Default 3.4+: thriftpy_sync

There are 4 types of workers available.

  • thrift_sync: sync worker.
  • thrift_gevent: gevent worker.
  • thriftpy_sync: sync worker, adapted for thriftpy2
  • thriftpy_gevent: gevent worker, adapted for thriftpy2

note: If you want to use thriftpy_sync or thriftpy_gevent, make sure the following:

  • Version of thriftpy2 should be higher than 0.1.10.
  • --thrift-protocol-factory should be set to either:
    1. thriftpy2.protocol:TCyBinaryProtocolFactory or
    2. thriftpy2.protocol:TBinaryProtocolFactory
  • --thrift-transport-factory should be set to either:
    1. thriftpy2.transport:TCyBufferedTransportFactory or
    2. thriftpy2.transport:TBufferedTransportFactory

Transport factory

The transport factory to use for handling connections.

Parameter: --thrift-transport-factory
Config file: thrift_transport_factory
Default 2.7: thrift.transport.TTransport:TBufferedTransportFactory
Default 3.4+: thriftpy2.transport:TBufferedTransportFactory

Protocol factory

The protocol factory to use for parsing requests.

Parameter: --thrift-protocol-factory
Config file: thrift_protocol_factory
Default 2.7: thrift.protocol.TBinaryProtocol:TBinaryProtocolAcceleratedFactory
Default 3.4+: thriftpy2.protocol:TBinaryProtocolFactory

Client timeout

Seconds to timeout a client if it is silent after this duration.

Parameter: --thrift-client-timeout
Config file: thrift_client_timeout
Default: None (Never time out a client)

Gevent check interval

This config will run a seperate thread to detect gevent ioloop block every specified seconds.

Parameter: --gevent-check-interval
Config file: gevent_check_interval
Default: 0

Note: DONOT USE this if not running gevent worker.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].