Skip to content

Commit

Permalink
Moved quit code into it's own method
Browse files Browse the repository at this point in the history
  • Loading branch information
heyman committed Oct 31, 2012
1 parent 37694fb commit dab68d2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ def on_slave_report(client_id, data):

# register listener that sends quit message to slave nodes
def on_quitting():
for client in self.clients.itervalues():
self.server.send(Message("quit", None, None))
self.quit()
events.quitting += on_quitting

@property
Expand Down Expand Up @@ -282,13 +281,21 @@ def stop(self):
for client in self.clients.hatching + self.clients.running:
self.server.send(Message("stop", None, None))

def quit(self):
for client in self.clients.itervalues():
self.server.send(Message("quit", None, None))
self.greenlet.kill(block=True)

def client_listener(self):
while True:
msg = self.server.recv()
if msg.type == "client_ready":
id = msg.node_id
self.clients[id] = SlaveNode(id)
logger.info("Client %r reported as ready. Currently %i clients ready to swarm." % (id, len(self.clients.ready)))
## emit a warning if the slave's clock seem to be out of sync with our clock
#if abs(time() - msg.data["time"]) > 5.0:
# warnings.warn("The slave node's clock seem to be out of sync. For the statistics to be correct the different locust servers need to have synchronized clocks.")
elif msg.type == "client_stopped":
del self.clients[msg.node_id]
if len(self.clients.hatching + self.clients.running) == 0:
Expand Down

0 comments on commit dab68d2

Please sign in to comment.