def start_hatching(self, locust_count=None, hatch_rate=None, wait=False): if self.state != STATE_RUNNING and self.state != STATE_HATCHING: RequestStats.clear_all() RequestStats.global_start_time = time() self.exceptions = {} # Dynamically changing the locust count if self.state != STATE_INIT and self.state != STATE_STOPPED: self.state = STATE_HATCHING if self.num_clients > locust_count: # Kill some locusts kill_count = self.num_clients - locust_count self.kill_locusts(kill_count) elif self.num_clients < locust_count: # Spawn some locusts if hatch_rate: self.hatch_rate = hatch_rate spawn_count = locust_count - self.num_clients self.spawn_locusts(spawn_count=spawn_count) else: if hatch_rate: self.hatch_rate = hatch_rate if locust_count: self.spawn_locusts(locust_count, wait=wait) else: self.spawn_locusts(wait=wait)
def start_hatching(self, locust_count, hatch_rate): self.num_clients = locust_count slave_num_clients = locust_count / ((len(self.clients.ready) + len(self.clients.running)) or 1) slave_hatch_rate = float(hatch_rate) / ((len(self.clients.ready) + len(self.clients.running)) or 1) logger.info("Sending hatch jobs to %i ready clients" % (len(self.clients.ready) + len(self.clients.running))) if not (len(self.clients.ready) + len(self.clients.running)): logger.warning( "You are running in distributed mode but have no slave servers connected. Please connect slaves prior to swarming." ) return if self.state != STATE_RUNNING and self.state != STATE_HATCHING: RequestStats.clear_all() for client in self.clients.itervalues(): data = { "hatch_rate": slave_hatch_rate, "num_clients": slave_num_clients, "num_requests": self.num_requests, "host": self.host, "stop_timeout": None, } self.server.send(Message("hatch", data, None)) RequestStats.global_start_time = time() self.state = STATE_HATCHING
def start_hatching(self, locust_count, hatch_rate): self.num_clients = locust_count slave_num_clients = locust_count / ( (len(self.clients.ready) + len(self.clients.running)) or 1) slave_hatch_rate = float(hatch_rate) / ( (len(self.clients.ready) + len(self.clients.running)) or 1) logger.info("Sending hatch jobs to %i ready clients" % (len(self.clients.ready) + len(self.clients.running))) if not (len(self.clients.ready) + len(self.clients.running)): logger.warning( "You are running in distributed mode but have no slave servers connected. Please connect slaves prior to swarming." ) return if self.state != STATE_RUNNING and self.state != STATE_HATCHING: RequestStats.clear_all() for client in self.clients.itervalues(): msg = { "hatch_rate": slave_hatch_rate, "num_clients": slave_num_clients, "num_requests": self.num_requests, "host": self.host, "stop_timeout": None } self.server.send({"type": "hatch", "data": msg}) RequestStats.global_start_time = time() self.state = STATE_HATCHING
def start_hatching(self, locust_count, hatch_rate): self.num_clients = locust_count slave_num_clients = locust_count / ((len(self.clients.ready) + len(self.clients.running)) or 1) slave_hatch_rate = float(hatch_rate) / ((len(self.clients.ready) + len(self.clients.running)) or 1) print "Sending hatch jobs to %i ready clients" % (len(self.clients.ready) + len(self.clients.running)) if not (len(self.clients.ready)+len(self.clients.running)): print "WARNING: You are running in distributed mode but have no slave servers connected." print "Please connect slaves prior to swarming." if self.state != STATE_RUNNING and self.state != STATE_HATCHING: RequestStats.clear_all() for client in self.clients.itervalues(): msg = {"hatch_rate":slave_hatch_rate, "num_clients":slave_num_clients, "num_requests": self.num_requests, "host":self.host, "stop_timeout":None} self.server.send({"type":"hatch", "data":msg}) RequestStats.global_start_time = time() self.state = STATE_HATCHING