當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。