def test_request(config, sender, message, ref_count_offset): """test_request.""" try: config = Config() config.DH_PARAMS_PEM = "./tests/dh.pem" config.CERT_CHAIN_PEM = "./tests/cert.pem" config.SYNCHRONOUS = False config.AUTO_RELEASE = False a = Chirp(sender.loop, config) message.data = b'hello' message.address = "127.0.0.1" message.port = config.PORT fut = sender.request(message) msg = a.get() assert msg.data == b'hello' a.send(msg).result() b = msg.release_slot() b.result() assert msg._msg_t is None msg.release() assert msg._msg_t is not None msg2 = fut.result() assert msg2._msg_t is None msg2.release() assert msg2._msg_t is not None p = fut.send_result() assert p is message finally: a.stop() msg = None msg2 = None assert len(gc.get_referrers(a)) == 1 + ref_count_offset
#!/usr/bin/env python3 from libchirp.queue import Chirp, Config, Loop, Message loop = Loop() config = Config() message = Message() config.DISABLE_ENCRYPTION = True config.PORT = 2992 message.data = b'hello' message.address = "127.0.0.1" message.port = 2998 try: chirp = Chirp(loop, config) chirp.send(message).result() msg = chirp.get() msg.release().result() print(msg.data) finally: chirp.stop() loop.stop()
#!/usr/bin/env python3 from libchirp.queue import Chirp, Config, Loop, Message loop = Loop(); config = Config() config.DISABLE_ENCRYPTION = True # Workers are usually asynchronous config.SYNCHRONOUS = False try: chirp = Chirp(loop, config) msg = chirp.get() print(msg.data) chirp.send(msg).result() msg.release().result() finally: chirp.stop() loop.stop()