0

我写了一个蝗虫脚本来测试一个网站。脚本很简单,只是一个请求重复了几次。

在具有 Linux Mint 和 Python 2.7.6 的虚拟机中,该脚本以正确的方式和我想要的方式工作。

例如,我在没有 Web 界面的情况下运行脚本,如下所示:

locust --no-web -n 10 -c 1 -r 1 -f /path/to/file/file_test.py

我在终端窗口中获​​得了正确的统计数据。

当我在另一个使用 CentOS 和 Python 2.7.11 的虚拟机上运行相同的脚本时,我收到以下错误:

[2016-05-20 12:26:03,954] nix/ERROR/stderr: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/locust/core.py", line 267, in run
    self.execute_next_task()
  File "/usr/local/lib/python2.7/site-packages/locust/core.py", line 293, in execute_next_task
    self.execute_task(task["callable"], *task["args"], **task["kwargs"])
  File "/usr/local/lib/python2.7/site-packages/locust/core.py", line 305, in execute_task
    task(self, *args, **kwargs)
  File "/data/IVV/multi_benchmark/locust_scripts/OD_skip_top_multi_query.py", line 15, in query1
    self.client.get(QUERY, verify=False)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 487, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/locust/clients.py", line 113, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/locust/clients.py", line 157, in _send_request_safe_mode
    return requests.Session.request(self, method, url, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 403, in send
    timeout=timeout
  File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 578, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 351, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 814, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connection.py", line 289, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py", line 308, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/local/lib/python2.7/ssl.py", line 352, in wrap_socket
    _context=self)
TypeError: __init__() got an unexpected keyword argument 'server_hostname'
[2016-05-20 12:26:04,911] nix/INFO/locust.runners: All locusts hatched: MyLocust: 1
[2016-05-20 12:26:04,911] nix/INFO/locust.runners: Resetting stats

你能帮我理解这个问题吗?非常感谢。

4

1 回答 1

0

这似乎是 urllib3 中的一个已知问题,它与您的脚本无关。见https://github.com/shazow/urllib3/issues/482

于 2016-05-20T12:21:16.863 回答