Git Product home page Git Product logo

Comments (4)

wooparadog avatar wooparadog commented on June 13, 2024

Hi, there're 2 problems with your setup.

  1. gunicorn_thrift should be started with

    gunicorn_thrift app:processor -k thriftpy_gevent --thrift-protocol-factory thriftpy.protocol:TBinaryProtocolFactory --thrift-transport-factory thriftpy.transport:TBufferedTransportFactory --error-log - 

    please notice -k thriftpy_gevent rather than -k thrift_gevent

  2. service name not the same with thrift file. This might not be a problem, but out of some concerns, you should keep them the same.

    processor.register_processor("PingPong", app1)
    processor.register_processor("Hello", app2)
    

from gunicorn_thrift.

caiqingmao avatar caiqingmao commented on June 13, 2024

我使用了thriftpy_gevent代替了thrift_gevent,解决了上述的问题,但是当客户端和服务器端通信时,服务器端能返回正确的数据,但是也会出现异常,如下:

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/thriftpy_gevent_worker.py", line 88, in handle
    itrans.close()
  File "thriftpy/transport/buffered/cybuffered.pyx", line 38, in thriftpy.transport.buffered.cybuffered.TCyBufferedTransport.close (thriftpy/transport/buffered/cybuffered.c:1358)
  File "/Library/Python/2.7/site-packages/thriftpy/transport/socket.py", line 29, in close
    self.handle.shutdown(socket.SHUT_RDWR)
  File "/Library/Python/2.7/site-packages/gevent/socket.py", line 517, in shutdown
    self._sock.shutdown(how)
error: [Errno 57] Socket is not connected
<Greenlet at 0x107703730: <functools.partial object at 0x107780f70>(<socket at 0x1077b03d0 fileno=11 sock=127.0.0.1:80, ('127.0.0.1', 49525))> failed with error

客户端使用的是java,代码如下:

public static void main(String[] args) {
        try {
            TTransport tTransport = new TSocket("127.0.0.1", 8000);
            tTransport.open();
            TProtocol protocol = new TBinaryProtocol(tTransport);
            TMultiplexedProtocol hello = new TMultiplexedProtocol(protocol, "hello");
            Hello.Client client = new Hello.Client(hello);
            String response = client.hello2015();
            System.out.println(response);
            tTransport.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

能否帮忙分析一下哪里的代码出现了问题

启动方式
gunicorn_thrift app:processor -k thriftpy_gevent --thrift-protocol-factory thriftpy.protocol:TBinaryProtocolFactory --thrift-transport-factory thriftpy.transport:TBufferedTransportFactory --error-log -

from gunicorn_thrift.

wooparadog avatar wooparadog commented on June 13, 2024

尝试升级一下 thriftpy 的版本吧.

Thriftpy/thriftpy@40f97ec

from gunicorn_thrift.

caiqingmao avatar caiqingmao commented on June 13, 2024

解决了,谢谢。

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.