Git Product home page Git Product logo

Comments (4)

rkoval avatar rkoval commented on June 1, 2024

@dragonpaw was there any additional config that you needed to add to get it working with the thriftpy_gevent worker? i'm still unable to utilize it on 0.2.12, which is the version that corresponds to your PR.

my app would work under the thriftpy_sync worker with the command:

$ gunicorn_thrift index:app \
  --bind 127.0.0.1:9090 \
  --chdir thrift \
  --worker-class thriftpy_sync \
  --thrift-protocol-factory thriftpy.protocol:TCyBinaryProtocolFactory \
  --thrift-transport-factory thriftpy.transport:TCyBufferedTransportFactory

... but when i change the worker-class to thriftpy_gevent, which would be in the AVAILABLE_WORKERS in six.py:

$ gunicorn_thrift index:app \
  --bind 127.0.0.1:9090 \
  --chdir thrift \
  --worker-class thriftpy_gevent \
  --thrift-protocol-factory thriftpy.protocol:TCyBinaryProtocolFactory \
  --thrift-transport-factory thriftpy.transport:TCyBufferedTransportFactory

i get a blank error response of just Error:. the behavior is the same if i use any of the other unsupported workers as well.

environment:

$ python --version
Python 3.5.1
$ pip freeze
gunicorn==19.4.5
gunicorn-thrift==0.2.12
ply==3.8
setproctitle==1.1.8
thriftpy==0.3.7

i also tried manually pip installing gevent into my dependencies as well just for effect, but i'm unsure if that did anything. i still get the same behavior.

i'm still pretty new to python in general, so i apologize if i missed something basic here...

from gunicorn_thrift.

dragonpaw avatar dragonpaw commented on June 1, 2024

We're running with the following config(s) for what it is worth:

gunicorn_config.py:

# -*- coding: utf-8 -*-

worker_class = "thriftpy_gevent"
thrift_protocol_factory = "thriftpy.protocol:TCyBinaryProtocolFactory"
thrift_transport_factory = "thriftpy.transport:TCyBufferedTransportFactory"

errorlog = "-"
loglevel = "info"

bind = "0.0.0.0:7070"
workers = {{grains.num_cpus}}
threads = {{grains.num_cpus}} * 4
worker_connections = 1000
backlog = 2048

import os
def on_connected(worker, addr):
    #worker.log.info("connected: %s", addr)
    os.environ['REMOTE_IP'] = addr[0]
    os.environ['REMOTE_PORT'] = str(addr[1])

The {{ grains.* }} represents some magic from Saltstack. The last bit is so we can debug where connections come from via environment variables.

For running the app we use runit, but basically the command comes out to exec chpst -uwww-data -n-5 gunicorn_thrift -c /etc/gunicorn_thrift.py awesome_company.{{grains.cluster}}.thrift.server:app where server.py defines an app object which is a TProcessor(FooThriftServiceClass, FooPythonClass)

from gunicorn_thrift.

wooparadog avatar wooparadog commented on June 1, 2024

The main topic aside. @dragonpaw I spotted a potential bug in your on_connected hook.
Gevent is capable of receiving many connections at the same time. You should use contextlocal to save IP/Port information, rather than os.environ.

We are using the following:

def on_connected(worker, addr):
    from ...ctx import g
    if addr:
        g.set_conn_meta('client_addr', addr[0])

Note: g is a threadlocal object that is imported after fork(so after gevent patch).

from gunicorn_thrift.

rkoval avatar rkoval commented on June 1, 2024

@dragonpaw thanks for the response! i was able to resolve my issue by using a configuration file. gunicorn seems to provide more informative startup error messages if you pass in a config file for it to read

from gunicorn_thrift.

Related Issues (20)

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.