Skip to content

Commit

Permalink
Merge pull request #1025 from cyberw/fix-reporting-of-last-samples-wh…
Browse files Browse the repository at this point in the history
…en-running-distributed

Ensure that the last samples get sent by slave and received by master.
  • Loading branch information
mbeacom authored Sep 26, 2019
2 parents 14bd777 + 568b6b2 commit d367cda
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ def stop(self):
def quit(self):
for client in self.clients.all:
self.server.send_to_client(Message("quit", None, client.id))
gevent.sleep(0.5) # wait for final stats report from all slaves
self.greenlet.kill(block=True)

def heartbeat_worker(self):
Expand Down Expand Up @@ -439,16 +440,20 @@ def worker(self):
elif msg.type == "quit":
logger.info("Got quit message from master, shutting down...")
self.stop()
self._send_stats() # send a final report, in case there were any samples not yet reported
self.greenlet.kill(block=True)

def stats_reporter(self):
while True:
data = {}
events.report_to_master.fire(client_id=self.client_id, data=data)
try:
self.client.send(Message("stats", data, self.client_id))
self._send_stats()
except:
logger.error("Connection lost to master server. Aborting...")
break

gevent.sleep(SLAVE_REPORT_INTERVAL)

def _send_stats(self):
data = {}
events.report_to_master.fire(client_id=self.client_id, data=data)
self.client.send(Message("stats", data, self.client_id))

0 comments on commit d367cda

Please sign in to comment.