Merge "Fix simulator stat printing"

This commit is contained in:
Jenkins 2016-05-08 16:24:16 +00:00 committed by Gerrit Code Review
commit 80d8b18ebf

View File

@ -389,6 +389,19 @@ def generate_messages(messages_count):
LOG.info("Messages has been prepared") LOG.info("Messages has been prepared")
def wrap_sigexit(f):
def inner(*args, **kwargs):
try:
return f(*args, **kwargs)
except SignalExit as e:
LOG.info('Signal %s is caught. Interrupting the execution',
e.signo)
for server in SERVERS:
server.stop()
return inner
@wrap_sigexit
def run_server(server, duration=None): def run_server(server, duration=None):
global IS_RUNNING global IS_RUNNING
SERVERS.append(server) SERVERS.append(server)
@ -415,6 +428,7 @@ def rpc_server(transport, target, wait_before_answer, executor, duration):
return server.dispatcher.endpoints[0] return server.dispatcher.endpoints[0]
@wrap_sigexit
def spawn_rpc_clients(threads, transport, targets, wait_after_msg, timeout, def spawn_rpc_clients(threads, transport, targets, wait_after_msg, timeout,
is_cast, messages_count, duration): is_cast, messages_count, duration):
p = eventlet.GreenPool(size=threads) p = eventlet.GreenPool(size=threads)
@ -428,6 +442,7 @@ def spawn_rpc_clients(threads, transport, targets, wait_after_msg, timeout,
p.waitall() p.waitall()
@wrap_sigexit
def spawn_notify_clients(threads, topic, transport, message_count, def spawn_notify_clients(threads, topic, transport, message_count,
wait_after_msg, timeout, duration): wait_after_msg, timeout, duration):
p = eventlet.GreenPool(size=threads) p = eventlet.GreenPool(size=threads)
@ -660,7 +675,6 @@ def main():
signal.signal(signal.SIGTERM, signal_handler) signal.signal(signal.SIGTERM, signal_handler)
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
try:
if args.mode == 'rpc-server': if args.mode == 'rpc-server':
target = messaging.Target(topic=args.topic, server=args.server) target = messaging.Target(topic=args.topic, server=args.server)
if args.url.startswith('zmq'): if args.url.startswith('zmq'):
@ -702,10 +716,6 @@ def main():
if args.exit_wait: if args.exit_wait:
LOG.info("Finished. waiting for %d seconds", args.exit_wait) LOG.info("Finished. waiting for %d seconds", args.exit_wait)
time.sleep(args.exit_wait) time.sleep(args.exit_wait)
except SignalExit as e:
LOG.info('Signal %s is caught. Interrupting the execution', e.signo)
for server in SERVERS:
server.stop()
if __name__ == '__main__': if __name__ == '__main__':