Skip to content

Commit

Permalink
Fix urllib3 Recursion Regression (#410)
Browse files Browse the repository at this point in the history
* Fix urllib3 recursion

* Add regression testing for gevent

* [Mega-Linter] Apply linters fixes

* Add urllib3 to gevent tox env

Co-authored-by: TimPansino <TimPansino@users.noreply.github.com>
  • Loading branch information
TimPansino and TimPansino committed Oct 15, 2021
1 parent 0cf1f12 commit c52da17
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
Expand Up @@ -48,7 +48,7 @@
)
from ctypes.util import find_library

from urllib3.packages.six import raise_from
from ...packages.six import raise_from

if platform.system() != "Darwin":
raise ImportError("Only macOS is supported")
Expand Down
4 changes: 2 additions & 2 deletions newrelic/packages/urllib3/util/ssltransport.py
Expand Up @@ -2,8 +2,8 @@
import socket
import ssl

from urllib3.exceptions import ProxySchemeUnsupported
from urllib3.packages import six
from ..exceptions import ProxySchemeUnsupported
from ..packages import six

SSL_BLOCKSIZE = 16384

Expand Down
Expand Up @@ -12,8 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import gevent.monkey


def test_patch_thread():
import gevent.monkey

gevent.monkey.patch_thread()


def test_patch_ssl_recursion():
import gevent.monkey

gevent.monkey.patch_all()

# Delay imports and test creation of contexts from both bundled and installed urllib3
import urllib3.util.ssl_

import newrelic.packages.urllib3.util.ssl_

context1 = urllib3.util.ssl_.create_urllib3_context()
context2 = newrelic.packages.urllib3.util.ssl_.create_urllib3_context()
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -157,6 +157,7 @@ deps =
adapter_cheroot: cheroot
adapter_gevent: WSGIProxy2
adapter_gevent: gevent
adapter_gevent: urllib3
adapter_gunicorn-aiohttp1: aiohttp<2.0
adapter_gunicorn-aiohttp3: aiohttp<4.0
adapter_gunicorn-gunicorn19: gunicorn<20
Expand Down

0 comments on commit c52da17

Please sign in to comment.