def main(argv=None): opts = setup_options(argv) core.setup_logging(level=logging.WARN if opts.quiet else logging.DEBUG) if core.forkme_and_wait(opts.processes): # I'm the father and I'm done sys.exit(0) transport_url = core.rabbit_connection_url(driver='rabbit') transport = messaging.get_transport(cfg.CONF, transport_url) t = TestClient(transport) ctxt = {'a': 1} i = 0 errors = 0 try: while opts.num_messages == 0 or i < opts.num_messages: if opts.no_uuid: arg = opts.message else: arg = opts.message + str(uuid.uuid4()) LOG.debug("Requesting echo(%s)" % arg) try: response = t.echo(ctxt, arg) LOG.info("Got %r" % (response,)) assert arg == response, "%s != %s" % (arg, response) i += 1 except messaging.exceptions.MessagingTimeout as ex: LOG.warn('Received MessagingTimeout exception: %s' % str(ex)) errors += 1 if opts.publish_interval > 0: time.sleep(opts.publish_interval) if not opts.reuse_transport: renew = True if opts.renew_transport > 0 and i % opts.renew_transport != 0: renew = False if renew: if opts.transport_cleanup: # removes the reply_* queue associated with this # transport t._client.transport.cleanup() transport = messaging.get_transport(cfg.CONF, transport_url) t = TestClient(transport) except KeyboardInterrupt: # TODO: clean connections and asdf sys.exit(0)
def main(): args = setup_options() core.setup_logging(level=logging.WARN if args.quiet else logging.DEBUG) if core.forkme_and_wait(args.processes): # I'm the father and I'm done sys.exit(0) rpc = RpcClient() rpc.routing_key = args.routing_key i = 0 try: while args.num_messages == 0 or i < args.num_messages: arg = str(uuid.uuid4()) LOG.debug("Requesting echo(%s)" % arg) response = rpc.call(arg) LOG.info("Got %r" % (response,)) assert arg == response, "%s != %s" % (arg, response) i += 1 time.sleep(args.publish_interval) except KeyboardInterrupt: # TODO: clean connections and asdf sys.exit(0)