本文整理汇总了Python中stats.RequestStats.clear_all方法的典型用法代码示例。如果您正苦于以下问题:Python RequestStats.clear_all方法的具体用法?Python RequestStats.clear_all怎么用?Python RequestStats.clear_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stats.RequestStats
的用法示例。
在下文中一共展示了RequestStats.clear_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start_hatching
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import clear_all [as 别名]
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)
示例2: start_hatching
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import clear_all [as 别名]
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
示例3: start_hatching
# 需要导入模块: from stats import RequestStats [as 别名]
# 或者: from stats.RequestStats import clear_all [as 别名]
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