Thrift app and worker for gunicorn!
- graceful reload/shutdown.
- manage worker number at runtime.
- and everything else
gunicorn
has to offer.
-
Generate thrift files:
% thrift --out tests/pingpong_sdk --gen py:new_style,utf8strings tests/pingpong.thrift
-
Write thrift app.
#! /usr/bin/env python # tests/app.py # -*- coding: utf-8 -*- import os from pingpong_sdk.pingpong import PingService class PingpongServer(object): def ping(self): return "pong" app = PingService.Processor(PingpongServer())
-
Fire up app.
% gunicorn_thrift tests.app:app -k thrift_sync % gunicorn_thrift tests.app:app -k thrift_gevent
There are 4 types of workers avaiable.
thrift_sync
: sync worker.thrift_gevent
: gevent worker.thriftpy_sync
: sync worker, adapted forthriftpy
thriftpy_gevent
: gevent worker, adapted forthriftpy
The transport factory to use for handling connections.
default: thrift.transport.TTransport:TBufferedTransportFactory
The protocol factory to use for parsing requests.
default: thrift.protocol.TBinaryProtocol:TBinaryProtocolAcceleratedFactory
Seconds to timeout a client if it is silent after this duration.
default: None
(Never time out a client)