How to use the broker.Broker.Processor function in broker

To help you get started, we’ve selected a few broker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gdeetotdom / thriftpool / benchs / old / gevent_thrift_server.py View on Github external
from broker.ttypes import Result
from socket_zmq.thrift_server import TGeventStreamServer
from gevent.greenlet import Greenlet
from setproctitle import setproctitle


class BrokerHandler:
    a = '0' * 256

    def execute(self, task):
        return Result(self.a)


listener = ('localhost', 9090)
handler = BrokerHandler()
processor = Broker.Processor(handler)


server = TGeventStreamServer(listener, processor)


def main():
    print 'Starting server'
    Greenlet(server.stop).start_later(30)
    server.serve_forever()

if __name__ == '__main__':
    setproctitle('[server]')
    #main()
    import cProfile
    cProfile.runctx("main()", globals(), locals(), "server.prof")
github gdeetotdom / thriftpool / benchs / old / non_block_thrift_server.py View on Github external
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol
from thrift.server import TServer
from thrift.protocol.TBinaryProtocol import TBinaryProtocolAcceleratedFactory


class BrokerHandler:
    a = '0' * 256

    def execute(self, task):
        return Result(self.a)


listener = ('localhost', 9090)
handler = BrokerHandler()
processor = Broker.Processor(handler)
transport = TSocket.TServerSocket(listener[0], listener[1])
tfactory = TBinaryProtocolAcceleratedFactory()
pfactory = TBinaryProtocolAcceleratedFactory()

# set server
server = TNonblockingServer(processor, transport, tfactory, pfactory)

print 'Starting server'
server.serve()
github gdeetotdom / thriftpool / benchs / worker.py View on Github external
def main():
    processor = TBroker.Processor(BrokerHandler())
    worker = factory.Worker(processor)
    worker.run()