def test(addr): service = MalamuteClient() service.connect(addr, 100, b'service') service.set_worker(b'service', b'derps') writer = MalamuteClient() print("writer.connect") writer.connect(addr, 100, b'writer') print("writer.set_producer") writer.set_producer(b'writer') reader = MalamuteClient() print("reader.connect") reader.connect(addr, 100, b'reader') print("reader.set_consumer") reader.set_consumer(b'writer', b'foo') reader.set_consumer(b'writer', b'bar') print("writer.send") writer.send(b'foo', [b'whoaaa', b'whaaaaaa']) writer.send(b'bar', [b'whoaaa', b'whaaaaaa']) print(reader.recv()) print(reader.recv()) reader.sendfor(b'service', b'derps', None, 100, [b'foooooo']) reader.sendfor(b'service', b'derps', None, 100, [b'foooooo']) reader.sendfor(b'service', b'derps', None, 100, [b'foooooo']) print(service.recv()) print(service.recv()) print(service.recv()) service.sendto(b'reader', b'response', None, 100, [b'ok']) print(reader.recv())
def publish(addr, who, url): writer = MalamuteClient() print_and_flush("connect") writer.connect(addr, 100, who) print_and_flush("set_producer") writer.set_producer(PRODUCER) while True: now = datetime.datetime.now() writer.send(url, [b'success', str(now).encode(UTF8)]) time.sleep(10)