在使用locust my site进行负载测试时,例如
locust -f mysite_loadtest.py --host=https://beta.mysite.com我使用以下代码(摘录):
class Details(TaskSet):
"""IP details queries group"""
def on_start(self):
self.client.verify = False # Don't to check if certificate is valid
@task
def details_ip(self):
response = self.client.get("/main")
class TaskList(TaskSet):
tasks = [Details]
class APIUser(HttpLocust):
task_set = TaskList
min_wait = 0
max_wait = 3000我得到了大量的错误信息,比如:
[2017-02-08 05:26:34,988] beta.mysite.com/ERROR/stderr: /usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
[2017-02-08 05:26:34,988] beta.mysite.com/ERROR/stderr: /usr/lib/python2.6/site-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
[2017-02-08 05:26:35,008] beta.mysite.com/ERROR/stderr: /usr/lib/python2.6/site-packages/requests/packages/urllib3/connectionpool.py:791: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)有没有可能以任何方式抑制这些错误写入到stdout?
发布于 2017-02-08 22:55:10
这将忽略警告:
import warnings
warnings.filterwarnings("ignore")如果上面的解决方案不起作用,请尝试:
import os
import sys
f = open(os.devnull, 'w')
sys.stdout = f这会将您的错误输出重定向为null (不会显示)。
https://stackoverflow.com/questions/42116359
复制相似问题