Skip to content

Commit

Permalink
Use uuid4 to generate slave client_id
Browse files Browse the repository at this point in the history
Fixes locustio#894 

Current implementation collides easily in environments with large number of slave processes on the same host starting at the same time.
  • Loading branch information
mattbailey committed Sep 27, 2018
1 parent 3686171 commit 918f6d0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions locust/runners.py
Expand Up @@ -4,7 +4,7 @@
import socket
import traceback
import warnings
from hashlib import md5
from uuid import uuid4
from time import time

import gevent
Expand Down Expand Up @@ -352,7 +352,7 @@ def slave_count(self):
class SlaveLocustRunner(DistributedLocustRunner):
def __init__(self, *args, **kwargs):
super(SlaveLocustRunner, self).__init__(*args, **kwargs)
self.client_id = socket.gethostname() + "_" + md5(str(time() + random.randint(0,10000)).encode('utf-8')).hexdigest()
self.client_id = socket.gethostname() + "_" + uuid4().hex

self.client = rpc.Client(self.master_host, self.master_port)
self.greenlet = Group()
Expand Down

0 comments on commit 918f6d0

Please sign in to comment.