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


Python locust.Locust方法代码示例

本文整理汇总了Python中locust.Locust方法的典型用法代码示例。如果您正苦于以下问题:Python locust.Locust方法的具体用法?Python locust.Locust怎么用?Python locust.Locust使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在locust的用法示例。


在下文中一共展示了locust.Locust方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: teardown

# 需要导入模块: import locust [as 别名]
# 或者: from locust import Locust [as 别名]
def teardown(self):
        print("Locust ends his tasks") 
开发者ID:IntelAI,项目名称:inference-model-manager,代码行数:4,代码来源:image_locust.py

示例2: __init__

# 需要导入模块: import locust [as 别名]
# 或者: from locust import Locust [as 别名]
def __init__(self, *args, **kwargs):
        super(Locust, self).__init__(*args, **kwargs)
        if self.host is None:
            raise LocustError("You must specify a host")

        #TODO: Current implementation sets an empty client_id when the connection is initialized,
        #      which Paho handles by creating a random client_id. 
        #		Ideally we want to control the client_id that is set in Paho. Each client_id
        #		should match a thing_id in the AWS IoT Thing Registry
        #self.client = MQTTClient(self.client_id)
        self.client = MQTTClient()
        try:
            [host, port] = self.host.split(":")
        except:
            host, port = self.host, 8883

        try:
          self.client.tls_set(self.ca_cert, self.iot_cert, self.iot_private_key, tls_version=ssl.PROTOCOL_TLSv1_2)
          #It is important to do an asynchronous connect, given that we will have
          #multiple connections happening in a single server during a Locust test
          self.client.connect_async(host, port)
          self.client.loop_start()
        except Exception as e:
            fire_locust_failure(
                request_type=REQUEST_TYPE,
                name='connect',
                response_time=time_delta(start_time, time.time()),
                exception=ConnectError("Could not connect to host:["+host+"]")
            ) 
开发者ID:concurrencylabs,项目名称:mqtt-locust,代码行数:31,代码来源:mqtt_locust.py


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