使用我的网站蝗虫进行负载测试,例如
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)
是否有可能以任何方式禁止那些ERROR写入stdout?
答案 0 :(得分:2)
这会忽略警告:
import warnings
warnings.filterwarnings("ignore")
如果上述解决方案无效,请尝试:
import os
import sys
f = open(os.devnull, 'w')
sys.stdout = f
这会将您的错误输出重定向到null(它不会显示)。