本文整理汇总了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")
示例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+"]")
)