[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
This commit is contained in:
parent
874a69b0cd
commit
6eb57b4d5f
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user