Ejemplo n.º 1
0
def test_messaging(socket, addr, topic):
    push = socket(zmq.PUSH)
    pull = socket(zmq.PULL)
    link_sockets(addr, push, [pull])
    for t in [b'', topic]:
        zeronimo.messaging.send(push, [b'doctor'], b'who', (t,))
        assert zeronimo.messaging.recv(pull) == ([b'doctor'], b'who', [t])
    with pytest.raises(TypeError):
        zeronimo.messaging.send(push, 1)
Ejemplo n.º 2
0
def test_eintr_retry_zmq(itimer, signo, socket, addr):
    push = socket(zmq.PUSH)
    pull = socket(zmq.PULL)
    link_sockets(addr, push, [pull])
    interrupted_frames = []
    def handler(signo, frame):
        interrupted_frames.append(frame)
    prev_handler = signal.signal(signo, handler)
    prev_itimer = signal.setitimer(itimer, 0.001, 0.001)
    for x in itertools.count():
        eintr_retry_zmq(push.send, bytes(x))
        assert eintr_retry_zmq(pull.recv) == bytes(x)
        if len(interrupted_frames) > 100:
            break
    signal.setitimer(itimer, *prev_itimer)
    signal.signal(signo, prev_handler)