Git Product home page Git Product logo

gunicorn_thrift's Introduction

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.

gunicorn_thrift's People

Contributors

aawilson avatar air-upc avatar aisk avatar alexband avatar ethe avatar hit9 avatar pawl-rs avatar ritksm avatar ryanwang520 avatar suzaku avatar wkingfly avatar wooparadog avatar xyg-coder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gunicorn_thrift's Issues

The gunicorn got timeout but not exit

I'm use the gunicorn_thrift like last issues,some time is run well ,but when it run a while ,I got a error

1741648 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7438)
1741649 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7445)
1741650 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7447)
1741651 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7448)
1741652 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7449)
1741653 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7451)
1741654 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7453)
1741655 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7456)
1741656 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7457)
1741657 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7458)
1741658 [2017-12-06 12:15:39 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7459)
1741659 [2017-12-06 12:15:40 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7434)
1741660 [2017-12-06 12:15:40 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7437)
1741661 [2017-12-06 12:15:40 +0000] [5727] [CRITICAL] WORKER TIMEOUT (pid:7443)
1741662 [2017-12-06 12:15:40 +0000] [7506] [INFO] Booting worker with pid: 7506
1741663 [2017-12-06 12:15:40 +0000] [7507] [INFO] Booting worker with pid: 7507
1741664 [2017-12-06 12:15:40 +0000] [7508] [INFO] Booting worker with pid: 7508
1741665 [2017-12-06 12:15:40 +0000] [7509] [INFO] Booting worker with pid: 7509
1741666 [2017-12-06 12:15:40 +0000] [7510] [INFO] Booting worker with pid: 7510
1741667 [2017-12-06 12:15:40 +0000] [7511] [INFO] Booting worker with pid: 7511
1741668 [2017-12-06 12:15:40 +0000] [7512] [INFO] Booting worker with pid: 7512
1741669 [2017-12-06 12:15:40 +0000] [7513] [INFO] Booting worker with pid: 7513
1741670 [2017-12-06 12:15:40 +0000] [7514] [INFO] Booting worker with pid: 7514
1741671 [2017-12-06 12:15:40 +0000] [7515] [INFO] Booting worker with pid: 7515
1741672 [2017-12-06 12:15:40 +0000] [7514] [ERROR] Exception in worker process:
1741673 Traceback (most recent call last):
1741674   File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
1741675     worker.init_process()
1741676   File "/usr/local/lib/python2.7/site-packages/gunicorn_thrift/thriftpy_gevent_worker.py", line 98, in init_process
1741677     return super(GeventThriftPyWorker, self).init_process()
1741678   File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 192, in init_process
1741679     super(GeventWorker, self).init_process()
1741680   File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
1741681     self.wsgi = self.app.wsgi()
1741682   File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
1741683     self.callable = self.load()
1741684   File "/usr/local/lib/python2.7/site-packages/gunicorn_thrift/thriftapp.py", line 39, in load
1741685     self.thrift_app = self.load_thrift_app()
1741686   File "/usr/local/lib/python2.7/site-packages/gunicorn_thrift/thriftapp.py", line 33, in load_thrift_app
1741687     return utils.load_obj(self.app_uri)
1741688   File "/usr/local/lib/python2.7/site-packages/gunicorn_thrift/utils.py", line 16, in load_obj
1741689     mod = importlib.import_module(module)
1741690   File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
1741691     __import__(name)
1741692   File "/usr/local/lib/python2.7/site-packages/gevent-1.1rc2-py2.7-linux-x86_64.egg/gevent/builtins.py", line 58, in __import__
1741693     result = _import(*args, **kwargs)
1741694   File "/home/zhouyi/heybox_script/release/pubg_thriftpy/pubg_account_server.py", line 13, in <module>
1741695     pg_account = psycopg2.connect(database="account", user='postgres', password="", host="10.10.10.54", port='19934')
1741696   File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
1741697     conn = _connect(dsn, connection_factory=connection_factory, async=async)
1741698 OperationalError: FATAL:  sorry, too many clients already

it seems like the WORKER got timeout but not exit so the master booting another worker , finally the worker connect to pg got the ' too many clients' error, anyone know what's the problem ?

有个疑问?

Thrift server 本身不就有多进程模型吧 ,你让gunicorn 兼容thrift的协议是为了使用gunicorn的进程管理模型么? 好奇...

请问是否支持TMultiplexedProcessor?

写了一个thrift文件
service PingPong {
string ping()
}
service Hello{
string hello2015()
}

然后使用thriftpy

import thriftpy
from thriftpy.thrift import TProcessor
from thriftpy.thrift import TMultiplexedProcessor

class PingPongDispatcher(object):
def ping(self):
return "pong"

class HelloDispatcher(object):
def hello2015(self):
return "hello2015"

pingpong_thrift = thriftpy.load("pingpong.thrift")
app1 = TProcessor(pingpong_thrift.PingPong, PingPongDispatcher())
app2 = TProcessor(pingpong_thrift.Hello, HelloDispatcher())
processor = TMultiplexedProcessor()
processor.register_processor("pingpong", app1)
processor.register_processor("hello", app2)

然后使用gunicorn_thrift启动
gunicorn_thrift app:processor -k thrift_gevent --thrift-protocol-factory thriftpy.protocol:TBinaryProtocolFactory --thrift-transport-factory thriftpy.transport:TBufferedTransportFactory --error-log -

客户端使用的是java、访问python服务器端时出现错误

[2015-08-29 14:09:49 +0800] [719] [ERROR] 'TCyBufferedTransportFactory' object has no attribute 'getTransport'
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/gunicorn_thrift/gevent_worker.py", line 42, in handle
self.get_thrift_transports_and_protos(result)
File "/Library/Python/2.7/site-packages/gunicorn_thrift/gevent_worker.py", line 25, in get_thrift_transports_and_protos
itrans = self.app.tfactory.getTransport(result)
AttributeError: 'TCyBufferedTransportFactory' object has no attribute 'getTransport'
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/gevent/greenlet.py", line 327, in run
result = self._run(_self.args, *_self.kwargs)
File "/Library/Python/2.7/site-packages/gunicorn_thrift/gevent_worker.py", line 59, in handle
itrans.close()
UnboundLocalError: local variable 'itrans' referenced before assignment
<Greenlet at 0x104e74870: <functools.partial object at 0x104ea4ec0>(<socket at 0x104f24750 fileno=11 sock=127.0.0.1:80, ('127.0.0.1', 49831))> failed with UnboundLocalError

请问这是怎么回事?本人新手学习thriftpy和使用gunicorn_thrift、跪请大神回复

Implement gthread worker

I'm going to take a crack at this, so here's an issue for me to reference later:

TODO:

  • Implement a worker for gthread
  • Make some tests
  • Throw some crap at it

线上偶现请求时间过长问题

项目使用 gunicorn_thrift + thriftpy2,接口正常请求时间400ms左右,但是持续请求测试时,客户端打印请求时间发现,偶尔会出现十几秒甚至几十秒的请求时间(我timeout设置比较大)。接口本身逻辑简单且服务端(业务代码)打印请求时间正常。线上请求量不算大,QPS最高也就300r/s
不知道你们有没有遇到过类似问题......

gunicorn + thriftpy2 使用上的几点疑问

您好! 请问关于使用thriftpy2 + gunicorn_thrift + gevent worker-class 使用场景来再生产环境里,增强thriftpy server吞吐性能使用场景,我遇到如下几个问题,特来请教大神:
(1) 对于使用thrfitpy2框架,并业务handler里,处理一条请求里有较多rpc访问,我理解上述 gunicorn 多worker进程 + 每个worker使用gevent类型,应该是性能最佳的组合? 当然我没有实践,跟@ethe 确认
(2) 我看worker-class = gevent 只适用于protocol=TBinaryProtocol 和 transport=TBufferedTransport, transport不支持TFramedTransport么?
(3) 我原来使用thriftpy2 make_server接口,采用的TthreadServer, 多线程模式并发处理请求,业务处理handler里,需要在处理并发请求时,加锁,做一些同步处理,这种场景,改为gunicorn_thrift fork多worker进程模式,应当如何保障在多个worker进程处理请求时,共享一个全局的进程锁,多worker同步了?

@ethe 能否在百忙之中,及时帮我们答疑解惑了? 万分感谢! 以及是否方便微信联系了? 我们在较大规模应用thriftpy2 以及相关组件

ImportError: No module named event

2016-04-21 15:07:26.090 err gunicorn.biz.shopping.error: [26817] ('10.0.40.20', 36547): ImportError('No module named events',)
Traceback (most recent call last):
  File "/srv/ves/biz.shopping/.venv/lib/python2.7/site-packages/gunicorn_thrift/thriftpy_gevent_worker.py", line 75, in handle
  File "/srv/ves/biz.shopping/.venv/lib/python2.7/site-packages/thriftpy/contrib/tracking/__init__.py", line 143, in process
  File "/srv/ves/biz.shopping/.venv/lib/python2.7/site-packages/thriftpy/contrib/tracking/__init__.py", line 195, in _do_process
  File "/srv/ves/biz.shopping/.venv/lib/python2.7/site-packages/thriftpy/thrift.py", line 254, in handle_exception
ImportError: No module named events

Support gevent on Python3

Gunicorn added support in 19.4 and gevent did in 1.1.

I tested gunicorn_thrift and the gevent worker with those versions, and it seems to work fine.

Update pypi distribution

I noticed installing from pypi and using a thriftpy_gevent worker is broken in the latest version 0.2.21.

image

Installing directly from this repo seems to solve the problem:
git+https://github.com/eleme/gunicorn_thrift.git

After further inspection the code looks pretty different on pypi
pypi 0.2.21
thriftpy_gevent_worker.py line 100
image

this repo:
image

Any chance of updating pypi distribution?

Thanks!

New Relic Agent / Monitoring

Hey Eleme.

For a few days I've been trying to use New Relic monitoring on my gunicorn_thrift app. I've had no issues with my traditional gunicorn apps. I can launch my gunicorn_thrift application with no issues, but new relic gets no data.

I can launch it with Gunicorn like so:

NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program [gunicorn commands here]

But if I use:

NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program gunicorn_thrift tests.thriftpy_app:app -k thriftpy_sync \
  --thrift-protocol-factory \
    thriftpy.protocol:TCyBinaryProtocolFactory \
  --thrift-transport-factory \
    thriftpy.transport:TCyBufferedTransportFactory

I get no errors, but no communication to new relic.

https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-admin-script

Any advice for me?

Is it right always log a full stack exception?

In my situation, I just set client timeout as low as possible described in #45, but i always got a timeout message like Thriftpy/thrift_connector#48 said.

At last, I found that in https://github.com/eleme/gunicorn_thrift/blob/master/gunicorn_thrift/thriftpy_sync_worker.py#L75, it always log exception with full error stack.

But I think we should first identify to exception like below:

if isinstance(e, socket.timeout):
    self.log.info("timeout")
else:
    self.log.exception(e)

when i use gunicorn_thrift to start thriftpy2 app, one worker just can accept one client connection

from thriftpy2.rpc import make_server
make_server(): this way start app, it can accept several client connection. but when i change to use gunicorn_thrift ,one worker just can accept one client connection.

--worker-connections INT
                        The maximum number of simultaneous clients. [1000]

i have add the parameter “--worker-connections” explicitly.

cmd:

rpc.rpc_server:app -k thriftpy_sync -b 0.0.0.0:6000 -w 1 --threads 1 --worker-connections 2 -t 5 --thrift-protocol-factory thriftpy2.protocol:TCyBinaryProtocolFactory --thrift-transport-factory thriftpy2.transport:TCyBufferedTransportFactory --log-level debug

Gevent support in Python 3

Gevent 1.2 supports 3.4+ according to their documentation (3.3+ less officially), so theoretically this library shouldn't have any problems supporting thriftpy_gevent in 3.4+ (3.3+). I propose, then, that it should (and if it does, the README should reflect that)

Is this repo alive?

when I use gunicorn_thrift -c gunicorn.py pythriftServer:app to launch my thrifypy2 app, import error occured like follow

(monitor) ➜  pythriftCoco gunicorn_thrift -c gunicorn.py pythriftServer:app
Traceback (most recent call last):
  File "/home/cicada/.pyenv/versions/monitor/bin/gunicorn_thrift", line 7, in <module>
    from gunicorn_thrift.thriftapp import run
  File "/home/cicada/.pyenv/versions/3.6.5/envs/monitor/lib/python3.6/site-packages/gunicorn_thrift/thriftapp.py", line 11, in <module>
    from . import config
  File "/home/cicada/.pyenv/versions/3.6.5/envs/monitor/lib/python3.6/site-packages/gunicorn_thrift/config.py", line 4, in <module>
    from gunicorn import six
ImportError: cannot import name 'six'

maybe gunicorn_thrift version is not matched with gunicorn

Configure worker number

Hi. Is there some way to do more grained configuration in gunicorn_thrift just like gunicorn? E.g. worker number or thread number.

关于SO_REUSEPORT的问题

使用了reuse_port=True 起了8个worker进程
但是 netstat -tunlp的时候 发现只有一个进程在监听端口
是不是SO_REUSEPORT没有效果,还是哪有什么问题?

没有及时回收socket

thriftpy2, 在client退出后,服务端检查还有这个连接的socket在ESTABLISHED状态。这个有什么方法可以主动关闭么?
目前使用了thrift_client_timeout, 但是依然不理想

gunicorn version in requirements.txt

Here is the situation I ran into:

In my project requirements.txt, I use gunicorn==19.1.1 and gunicorn_thrift master branch via git.

Then I run pip install -r requirements.txt, pip freeze, and gunicorn is 19.1.1. After that I try to run gunicorn_thrift, but error occur:

Traceback (most recent call last):
  File "/virtualenv/bin/gunicorn_thrift", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/virtualenv/lib/python2.7/site-packages/pkg_resources.py", line 3011, in <module>
    parse_requirements(__requires__), Environment()
  File "/virtualenv/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: gunicorn==19.1.0

Maybe a better way to write requirements.txt should be using gunicorn>=19.1.0, instead of gunicorn==19.1.0?
Also by doing this, if we got some issues caused by upstream changes, we can fix it in time.

@wooparadog

gunicorn_thrift with http query

Hello,

I was trying to bringup gunicorn_thrift with http instead of roc to make it work under heroku load balancers.

I am facing issues when pushed gunicorn_thrift with rpc.
How can I change that to http?

Right now, I am bringing up app with

app = TProcessor(thrift_service,thrift_service_handler)

Can't use multiple CPU cores when starting thrift server with multiple workers

Hi,
I did a test and found a problem that bothered me.
I start gunicorn_thrift server and set --worker with the number of my cpu cores, it is 8.
Then I did the stress testing to the multiple workers server.
I found the total cpu usage of these 8 worker process is less than 100%, and the stress testing is broken.
I doubt if multiple worker server can use multiple cpu cores. Is it really a multi process with python server? Whether or not related to GIL with python.
Or, it is totally my program problem...

The following is some data of my testing:
    THREAD_NUM = 100    // thread number per round
    ONE_WORKER_NUM = 1000    // loop number of each thread
    LOOP_SLEEP = 0.1    // time interval of each loop

    PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                                                  
    20   0  221136  30468   7380 S  23.9  0.2   0:40.24 gunicorn: worker [PythonServer:processor]
    20   0  221196  30456   7380 S  20.9  0.2   0:33.67 gunicorn: worker [PythonServer:processor]
    20   0 2626964  18972   3564 S  19.6  0.1   0:03.06 python stress_test.py                                                                                                                  
    20   0  221116  30444   7380 S  17.0  0.2   0:29.29 gunicorn: worker [PythonServer:processor]
    20   0  221104  30440   7380 S  14.0  0.2   0:24.07 gunicorn: worker [PythonServer:processor]                                                                                       
    20   0  221100  30428   7380 S  11.3  0.2   0:18.64 gunicorn: worker [PythonServer:processor]
    20   0  221476  30416   7380 S   7.6  0.2   0:14.29 gunicorn: worker [PythonServer:processor]
    20   0  221332  30408   7380 S   6.6  0.2   0:11.93 gunicorn: worker [PythonServer:processor]
    20   0  221008  30144   7308 S   5.7  0.2   0:10.69 gunicorn: worker [PythonServer:processor]

gunicorn_thrift block problem with high concurrency

I was run thriftpy server as the readme suggest, and i used gunicorn_thrift as follow config

gunicorn_thrift account_server:app -w 60 \
  --worker-connections 2000 -k thriftpy_sync --thrift-protocol-factory thriftpy.protocol:TCyBinaryProtocolFactory \
    --thrift-transport-factory thriftpy.transport:TCyBufferedTransportFactory --threads 5  -D \
    --error-logfile /homex2/zhouyi/log/account_thrift_error.log --access-logfile /homex2/zhouyi/log/account_thrift_access.log\
      -b  0.0.0.0:16796 --reload  --forwarded-allow-ips 10.10.10.55

the test code was

import time
from multiprocessing import Process
import thriftpy
account_thrift = thriftpy.load("account.thrift", module_name="account_thrift")
from thriftpy.rpc import make_client

def main():
    thread_list = []
    start_time = time.time()
    for i in xrange(0,800):
        th = Process(target=process_func)
        th.start()
        thread_list.append(th)
    for i in thread_list:
        i.join()
    print time.time() - start_time

def process_func():
    th = MyThread()
    th.process_func()


class MyThread:
    def __init__(self):
        self.client = make_client(account_thrift.AccountRpc, '127.0.0.1', 16796)

    def process_func(self):
        for i in xrange(1,10000):
            print self.client.rpc_account_sid('account.5e4c769046c54b37a6f441fed028186d')
            time.sleep(0.5)


if __name__ == '__main__':
    r = main()

when i run the test code i got error with block
and i can't connect to the rpc server with other client too i got error
thriftpy.transport.TTransportException: TTransportException(message="Could not connect to ('127.0.0.1', 16796)", type=1)
, Is there any config error and what't the problem?

It seems -w parameter is very important but not in Readme.md?

I just run command like

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

,when I run on my computer, works well.
But on a server, some request always be hang on a long time.
i can't figure out which part got problem, thriftpy ? thrift_connector? gunicorn_thrift or even sqlalchemy.
finally, I found that one Process or called one worker only work for one connection. so i run into gunicorn documents find -w out.

so could you please add this parameter to Readme.md. so, someone else will not run in this trouble.

btw, could you please just share how to choose best client timeout and service timeout?

thanks.

No source distribution or Python 3 wheel on PyPI for 0.2.1

When I try to install dependencies for an application that uses gunicorn_thrift, I get errors from pip complaining about not finding a version that satisfies my given requirement.

Looking on PyPI, the only available distribution for gunicorn_thrift 0.2.1 is a Python 2 wheel.

Can you guys please upload an sdist and a Python 3 wheel?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.