From 6eb57b4d5f0a7057750c2f3d3fb0c3c8f23022e5 Mon Sep 17 00:00:00 2001
From: Kirill Bespalov <kbespalov@mirantis.com>
Date: Tue, 18 Oct 2016 14:34:14 +0300
Subject: [PATCH] [simulator] Fix a message length generator usage

Do initialization of the generator only for rpc/notify clients.
No needs to load messages_length.yaml and calculate distribution for servers.

Change-Id: Ib1ac30181bec20eacf6d29ccd5f76c0b6b1e96f8
---
 tools/simulator.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/tools/simulator.py b/tools/simulator.py
index f63028922..4bd70f085 100755
--- a/tools/simulator.py
+++ b/tools/simulator.py
@@ -38,7 +38,6 @@ from oslo_messaging import rpc  # noqa
 from oslo_utils import timeutils
 
 LOG = logging.getLogger()
-RANDOM_GENERATOR = None
 CURRENT_PID = None
 CURRENT_HOST = None
 CLIENTS = []
@@ -471,9 +470,9 @@ def generate_messages(messages_count):
     if messages_count > MESSAGES_LIMIT:
         messages_count = MESSAGES_LIMIT
     LOG.info("Generating %d random messages", messages_count)
-
+    generator = init_random_generator()
     for i in six.moves.range(messages_count):
-        length = RANDOM_GENERATOR()
+        length = generator()
         msg = ''.join(random.choice(
                       string.ascii_lowercase) for x in six.moves.range(length))
         MESSAGES.append(msg)
@@ -832,7 +831,6 @@ def main():
 
 
 if __name__ == '__main__':
-    RANDOM_GENERATOR = init_random_generator()
     CURRENT_PID = os.getpid()
     CURRENT_HOST = socket.gethostname()
     main()