Ejemplo n.º 1
0
#!/usr/bin/env python
"""
The front end of storage layer that handles the store request from the
collection layer
"""

import time
import struct
from pylib.wiring import gevent_zmq as zmq
import pylib.fastjson as json

from pylib import logger, conf
from pylib import wiring
from Queue import Queue

log = logger.getLogger(__name__)


def main():
    """main function"""
    context = zmq.Context()
    frontend = context.socket(zmq.ROUTER)
    frontend.bind('tcp://*:5570')

    backend = context.socket(zmq.DEALER)
    backend.bind('tcp://*:5571')

    poll = zmq.Poller()
    poll.register(frontend, zmq.POLLIN)
    poll.register(backend, zmq.POLLIN)
Ejemplo n.º 2
0
import time
import struct
from pylib.wiring import gevent_zmq as zmq
import pylib.fastjson as json

from pylib import logger, conf
from pylib import wiring
from Queue import Queue

log = logger.getLogger(__name__)

def main():
    """main function"""
    context = zmq.Context()
    socket = context.socket(zmq.DEALER)
    identity = u'client-2'
    socket.identity = identity.encode('ascii')
    socket.connect('tcp://localhost:5570')
    print 'Client %s started' % (identity)
    poll = zmq.Poller()
    poll.register(socket, zmq.POLLIN)
    reqs = 0
    count=0
    begin=time.time()
    while True:
        reqs = reqs + 1
        #print 'Req #%d sent..' % (reqs)
        socket.send_string(u'request #%d' % (reqs))
        #for i in range(5):
        sockets = dict(poll.poll(10))
        if socket in sockets: