当前位置: 首页>>代码示例>>Python>>正文


Python RequestStats.clear_all方法代码示例

本文整理汇总了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)
开发者ID:justinlundy,项目名称:locust,代码行数:28,代码来源:runners.py

示例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
开发者ID:amuraru,项目名称:locust,代码行数:29,代码来源:runners.py

示例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
开发者ID:d1on,项目名称:locust,代码行数:21,代码来源:core.py


注:本文中的stats.RequestStats.clear_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。