Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite recursion error when testing https sites #655

Closed
jobi opened this issue Sep 15, 2017 · 6 comments
Closed

Infinite recursion error when testing https sites #655

jobi opened this issue Sep 15, 2017 · 6 comments

Comments

@jobi
Copy link

jobi commented Sep 15, 2017

Description of issue / feature request

When opening a connection to an HTTPs site, I'm triggering an infinite recursion error:

[2017-09-14 22:19:39,370] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
[2017-09-14 22:19:39,386] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,386] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/locust/clients.py", line 114, in request
    response = self._send_request_safe_mode(method, url, **kwargs)
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/locust/clients.py", line 158, in _send_request_safe_mode
    return requests.Session.request(self, method, url, **kwargs)
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
[2017-09-14 22:19:39,387] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
    self._validate_conn(conn)
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
    conn.connect()
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/urllib3/connection.py", line 314, in connect
    cert_reqs=resolve_cert_reqs(self.cert_reqs),
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr: File "/Users/jbilien/src/scout-load/virtualenv/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 269, in create_urllib3_context
    context.options |= options
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr: File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 459, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr: File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 459, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
[2017-09-14 22:19:39,388] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,389] BOS-SC-JBil2/ERROR/stderr: File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py", line 459, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
[2017-09-14 22:19:39,389] BOS-SC-JBil2/ERROR/stderr:
[2017-09-14 22:19:39,389] BOS-SC-JBil2/ERROR/stderr: [Previous line repeated 316 more times]

A similar issue is being discussed at psf/requests#3752 and gevent/gevent#903. Suggestions to update to gevent 1.2 haven't helped.

Environment settings (for bug reports)

  • OS: macOS 10.12.6
  • Python version: 3.6.2
  • Locust version: 8c4eeae
@hamann
Copy link

hamann commented Sep 16, 2017

Getting the same error for https site

  • Alpine 3.6
  • Python version: 3.6.1
  • Locust version: 0.8a3

@heyman
Copy link
Member

heyman commented Sep 16, 2017

Could you provide a minimal locustfile that produces this error? If possible also specify some public host that the test can be run against. I was unable to reproduce it on Python 3.5 against https://google.com.

@heyman
Copy link
Member

heyman commented Sep 16, 2017

Oh, just realised that the two issues you linked were related to Python 3.6. Will try to reproduce with that.

@hamann
Copy link

hamann commented Sep 16, 2017

$ cat locustfile.py
from locust import HttpLocust, TaskSet, task

class HttpsTestBehaviour(TaskSet):

    @task(1)
    def get(self):
      self.client.get("/")

class HttpsTest(HttpLocust):
    task_set = HttpsTestBehaviour
    min_wait = 2
    max_wait = 5

$ cat Dockerfile
FROM alpine:3.6
RUN apk -U add ca-certificates python3 python3-dev py3-pip build-base && \
    pip3 install locustio==0.8a3 && \
    pip3 install pyzmq && \
    apk del python3-dev && \
    rm -r /var/cache/apk/*
ENTRYPOINT [ "/usr/bin/locust" ]
$ docker build -t local/locust:0.8a3 .
$ docker run --rm --net=host -v $PWD/locustfile.py:/locustfile.py local/locust:0.8a3 -f /locustfile.py --host=https://google.com

# open browser on http://localhost:8089 and watch errors in console

@heyman heyman closed this as completed in 4e9ab7e Sep 16, 2017
@heyman
Copy link
Member

heyman commented Sep 16, 2017

Found the issue! #651 had changed so that we applied the gevent monkey patching after we import requests which caused the issue. This is fixed in master now, and I'm about to push out a new version on PyPI.

@heyman
Copy link
Member

heyman commented Sep 16, 2017

New version released to PyPI.

rizalfr pushed a commit to erlanggakrisnamukti/locust that referenced this issue May 28, 2018
* find locustfile in the root directory

* Add ability to write out csv file data as part of command line run

* Update minimum version of gevent to fix locustio#598

* CSV flag, review comments

* Modify gevent wsgi and libev dependencies

* Sort all python imports

* Sort setup.py imports

* Standardize utf8 file coding declarations

* Bump version to 0.8a3 for another pre-release candidate

* Changed from deprecated method name

* Added test_suite argument to setup.py’s setup() method call

Not specifying the test_suite argument (using the default one) resulted in all tests being run multiple times (on Python 3.5). I haven’t looked in to why, since specifying “locust.test” should be correct, and fixes it.

* Suppress a warning that appears when running the tests on Python 3, that can cause tests (that depends on output to stderr) to fail.

* Apply gevent monkey patching before we import requests, to avoid infinite recursion error when doing SSL requests. Should fix locustio#655.

* Also patch threading when applying gevent monkey patch. Should fix locustio#569.

* Bumped version to 0.8a4

* Improved changelog

* Update main.py

Code comment and slightly more descriptive variable name

* More info about 0.8 to the Changelog

* Added some random examples that maybe could be useful to someone

* Bumped version to 0.8

* Upgrade pyzmq to latest stable version, and changed so that we do not pin the version (will make it easier to install Locust on Windows)

* Better installation instructions for Windows

* Bumped version to 0.8.1
pancaprima added a commit to erlanggakrisnamukti/locust that referenced this issue Aug 21, 2018
* Prima Update locust base version to 0.8.1 (#70)

* find locustfile in the root directory

* Add ability to write out csv file data as part of command line run

* Update minimum version of gevent to fix locustio#598

* CSV flag, review comments

* Modify gevent wsgi and libev dependencies

* Sort all python imports

* Sort setup.py imports

* Standardize utf8 file coding declarations

* Bump version to 0.8a3 for another pre-release candidate

* Changed from deprecated method name

* Added test_suite argument to setup.py’s setup() method call

Not specifying the test_suite argument (using the default one) resulted in all tests being run multiple times (on Python 3.5). I haven’t looked in to why, since specifying “locust.test” should be correct, and fixes it.

* Suppress a warning that appears when running the tests on Python 3, that can cause tests (that depends on output to stderr) to fail.

* Apply gevent monkey patching before we import requests, to avoid infinite recursion error when doing SSL requests. Should fix locustio#655.

* Also patch threading when applying gevent monkey patch. Should fix locustio#569.

* Bumped version to 0.8a4

* Improved changelog

* Update main.py

Code comment and slightly more descriptive variable name

* More info about 0.8 to the Changelog

* Added some random examples that maybe could be useful to someone

* Bumped version to 0.8

* Upgrade pyzmq to latest stable version, and changed so that we do not pin the version (will make it easier to install Locust on Windows)

* Better installation instructions for Windows

* Bumped version to 0.8.1

* Erlangga Add team_configuration property (#72)

* add get team configuration

* change read json path

* Rizal upload json file for team configuration (#68)

* enabling json uploading

* fix modal ui in upload json

* enabling upload on json also

* modify ui a bit and avoid duplicated message

* unify the function

* bug fix team configuration function (#88)

* change team_configuration function

* update configuration works
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants