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

SSLContext infinite recursion in Python 3.6 #1016

Closed
janbuchar opened this issue Sep 11, 2017 · 13 comments
Closed

SSLContext infinite recursion in Python 3.6 #1016

janbuchar opened this issue Sep 11, 2017 · 13 comments

Comments

@janbuchar
Copy link

On Python 3.6.2 and gevent 1.2.2, I encounter the problem described in #903 . I do not have the rights to reopen the issue, which is why I'm making a duplicate.

@jamadden
Copy link
Member

Can you please post a failing example and its output?

@janbuchar
Copy link
Author

The code:

import gevent
from gevent import monkey
import requests

monkey.patch_all()
from requests.packages.urllib3.util.ssl_ import create_urllib3_context
create_urllib3_context()

The output:

Traceback (most recent call last):                                                        
  File "gevent_requests.py", line 7, in <module>                                          
    create_urllib3_context()
  File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 269, in create_urllib
3_context             
    context.options |= options
  File "/usr/lib/python3.6/ssl.py", line 459, in options
    super(SSLContext, SSLContext).options.__set__(self, value)                            
  File "/usr/lib/python3.6/ssl.py", line 459, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/usr/lib/python3.6/ssl.py", line 459, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  [Previous line repeated 329 more times]    
RecursionError: maximum recursion depth exceeded while calling a Python object

@jamadden
Copy link
Member

Thanks. The problem is that you're importing requests before you monkey patch. You must monkey patch before importing anything else. I can reproduce this if I patch in the incorrect order, but if I patch in the correct order it works as expected:

Python 3.6.2 (default, Jul 18 2017, 14:08:57)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import gevent.monkey
>>> gevent.monkey.patch_all()
>>> from requests.packages.urllib3.util.ssl_ import create_urllib3_context
>>> create_urllib3_context()
<gevent._ssl3.SSLContext object at 0x1013c2228>

@janbuchar
Copy link
Author

Yes, that seems to be the problem - after fixing the order, everything is fine. I'm sorry for bothering you with this, I just googled the exception, found the issue I referenced and thought this must be the problem.

@jamadden
Copy link
Member

jamadden commented Sep 11, 2017

No worries. I will add a warning to gevent to make this more clear.

See also #941

@wumpus
Copy link

wumpus commented May 28, 2018

Thank you for the warning! Excellent way to point out coding errors.

@garyo
Copy link

garyo commented May 30, 2018

Is there a recommended way to initialize gevent with gunicorn to avoid this warning? I'm using Flask with gunicorn as server and gevent with websockets. I tried doing monkey.patch_all() in the gunicorn.conf.py in post_fork, but still get the warning.

@jamadden
Copy link
Member

I feel this has been said other places, but I personally monkey-patch before using gunicorn, in the initial boot script.

@garyo
Copy link

garyo commented May 30, 2018

So, you suggest starting gunicorn not on the command line but from a python module? And do the monkey-patching there? (Sorry to be obtuse, I'm just learning gunicorn -- only need to use it because I'm doing websockets in flask.)

@jamadden
Copy link
Member

Well, no. We use a setuptools entry point that wraps th gunicorn entry point. But it’s application specific.

@theladyjaye
Copy link

theladyjaye commented Jun 2, 2018

Is there anywhere else I could look that might cause this?

This here are the first few lines of my main.py:

1 print("Main Loading!")
2 import gevent
3 from gevent import monkey
4 monkey.patch_all()
5 print("Gevent Patched!")
6
7 from typing import Iterable, Optional, List

Here's what I see in my logs:

/var/task/main.py:4: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016

I am running this on the AWS Lambda python3.6 runtime

I cannot for the life of me understand how I can possibly import and patch any earlier than lines 2-4 (effectively line 1-3 as I dropped those print's in to see where it was happening)

I have some other Lambda's on the same python3.6 runtime that use gevent and patch in the same way and I do not receive this error. So I'm clearly missing something.

12 days later... (2018-06-13)

Ok so here is my Lambda deployment package and example code. It uses the Lambda handler main.aws_lambda

The only source present:

import sys
from pprint import pprint

# https://github.com/gevent/gevent/blob/master/src/gevent/monkey.py#L700
pprint(sys.modules)

import gevent.monkey
gevent.monkey.patch_all()


def aws_lambda(payload, _) -> None:
    print("Trial")

And from the logged output, the only line of note:

'ssl': <module 'ssl' from '/var/lang/lib/python3.6/ssl.py'>,

So AWS Lambda seems to already have SSL imported when it calls the entry point for the function. I don't know if this matters or falls under the python2 exception as documented here:

https://github.com/gevent/gevent/blob/master/src/gevent/monkey.py#L701-L704

If it does not matter, as in the python 2 notes, it looks like there is a runtime module available in the Python 3.6 AWS Lambda Runtime that could be used to detect this and ignore it:

'runtime': <module 'runtime' from '/var/runtime/awslambda/runtime.cpython-36m-x86_64-linux-gnu.so'>,

Code
Archive.zip

Log Output


{'__future__': <module '__future__' from '/var/lang/lib/python3.6/__future__.py'>,
'__main__': <module '__main__' from '/var/runtime/awslambda/bootstrap.py'>,
'_bisect': <module '_bisect' from '/var/lang/lib/python3.6/lib-dynload/_bisect.cpython-36m-x86_64-linux-gnu.so'>,
'_blake2': <module '_blake2' from '/var/lang/lib/python3.6/lib-dynload/_blake2.cpython-36m-x86_64-linux-gnu.so'>,
'_bootlocale': <module '_bootlocale' from '/var/lang/lib/python3.6/_bootlocale.py'>,
'_bz2': <module '_bz2' from '/var/lang/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so'>,
'_codecs': <module '_codecs' (built-in)>,
'_collections': <module '_collections' (built-in)>,
'_collections_abc': <module '_collections_abc' from '/var/lang/lib/python3.6/_collections_abc.py'>,
'_compression': <module '_compression' from '/var/lang/lib/python3.6/_compression.py'>,
'_datetime': <module '_datetime' from '/var/lang/lib/python3.6/lib-dynload/_datetime.cpython-36m-x86_64-linux-gnu.so'>,
'_decimal': <module '_decimal' from '/var/lang/lib/python3.6/lib-dynload/_decimal.cpython-36m-x86_64-linux-gnu.so'>,
'_frozen_importlib': <module 'importlib._bootstrap' (frozen)>,
'_frozen_importlib_external': <module 'importlib._bootstrap_external' (frozen)>,
'_functools': <module '_functools' (built-in)>,
'_hashlib': <module '_hashlib' from '/var/lang/lib/python3.6/lib-dynload/_hashlib.cpython-36m-x86_64-linux-gnu.so'>,
'_heapq': <module '_heapq' from '/var/lang/lib/python3.6/lib-dynload/_heapq.cpython-36m-x86_64-linux-gnu.so'>,
'_imp': <module '_imp' (built-in)>,
'_io': <module 'io' (built-in)>,
'_json': <module '_json' from '/var/lang/lib/python3.6/lib-dynload/_json.cpython-36m-x86_64-linux-gnu.so'>,
'_locale': <module '_locale' (built-in)>,
'_lzma': <module '_lzma' from '/var/lang/lib/python3.6/lib-dynload/_lzma.cpython-36m-x86_64-linux-gnu.so'>,
'_operator': <module '_operator' (built-in)>,
'_posixsubprocess': <module '_posixsubprocess' from '/var/lang/lib/python3.6/lib-dynload/_posixsubprocess.cpython-36m-x86_64-linux-gnu.so'>,
'_random': <module '_random' from '/var/lang/lib/python3.6/lib-dynload/_random.cpython-36m-x86_64-linux-gnu.so'>,
'_sha3': <module '_sha3' from '/var/lang/lib/python3.6/lib-dynload/_sha3.cpython-36m-x86_64-linux-gnu.so'>,
'_signal': <module '_signal' (built-in)>,
'_sitebuiltins': <module '_sitebuiltins' from '/var/lang/lib/python3.6/_sitebuiltins.py'>,
'_socket': <module '_socket' from '/var/lang/lib/python3.6/lib-dynload/_socket.cpython-36m-x86_64-linux-gnu.so'>,
'_sre': <module '_sre' (built-in)>,
'_ssl': <module '_ssl' from '/var/lang/lib/python3.6/lib-dynload/_ssl.cpython-36m-x86_64-linux-gnu.so'>,
'_stat': <module '_stat' (built-in)>,
'_string': <module '_string' (built-in)>,
'_struct': <module '_struct' from '/var/lang/lib/python3.6/lib-dynload/_struct.cpython-36m-x86_64-linux-gnu.so'>,
'_sysconfigdata_m_linux_x86_64-linux-gnu': <module '_sysconfigdata_m_linux_x86_64-linux-gnu' from '/var/lang/lib/python3.6/_sysconfigdata_m_linux_x86_64-linux-gnu.py'>,
'_thread': <module '_thread' (built-in)>,
'_warnings': <module '_warnings' (built-in)>,
'_weakref': <module '_weakref' (built-in)>,
'_weakrefset': <module '_weakrefset' from '/var/lang/lib/python3.6/_weakrefset.py'>,
'abc': <module 'abc' from '/var/lang/lib/python3.6/abc.py'>,
'argparse': <module 'argparse' from '/var/lang/lib/python3.6/argparse.py'>,
'atexit': <module 'atexit' (built-in)>,
'base64': <module 'base64' from '/var/lang/lib/python3.6/base64.py'>,
'binascii': <module 'binascii' from '/var/lang/lib/python3.6/lib-dynload/binascii.cpython-36m-x86_64-linux-gnu.so'>,
'bisect': <module 'bisect' from '/var/lang/lib/python3.6/bisect.py'>,
'builtins': <module 'builtins' (built-in)>,
'bz2': <module 'bz2' from '/var/lang/lib/python3.6/bz2.py'>,
'calendar': <module 'calendar' from '/var/lang/lib/python3.6/calendar.py'>,
'codecs': <module 'codecs' from '/var/lang/lib/python3.6/codecs.py'>,
'collections': <module 'collections' from '/var/lang/lib/python3.6/collections/__init__.py'>,
'collections.abc': <module 'collections.abc' from '/var/lang/lib/python3.6/collections/abc.py'>,
'contextlib': <module 'contextlib' from '/var/lang/lib/python3.6/contextlib.py'>,
'copy': <module 'copy' from '/var/lang/lib/python3.6/copy.py'>,
'copyreg': <module 'copyreg' from '/var/lang/lib/python3.6/copyreg.py'>,
'datetime': <module 'datetime' from '/var/lang/lib/python3.6/datetime.py'>,
'decimal': <module 'decimal' from '/var/lang/lib/python3.6/decimal.py'>,
'email': <module 'email' from '/var/lang/lib/python3.6/email/__init__.py'>,
'email._encoded_words': <module 'email._encoded_words' from '/var/lang/lib/python3.6/email/_encoded_words.py'>,
'email._parseaddr': <module 'email._parseaddr' from '/var/lang/lib/python3.6/email/_parseaddr.py'>,
'email._policybase': <module 'email._policybase' from '/var/lang/lib/python3.6/email/_policybase.py'>,
'email.base64mime': <module 'email.base64mime' from '/var/lang/lib/python3.6/email/base64mime.py'>,
'email.charset': <module 'email.charset' from '/var/lang/lib/python3.6/email/charset.py'>,
'email.encoders': <module 'email.encoders' from '/var/lang/lib/python3.6/email/encoders.py'>,
'email.errors': <module 'email.errors' from '/var/lang/lib/python3.6/email/errors.py'>,
'email.feedparser': <module 'email.feedparser' from '/var/lang/lib/python3.6/email/feedparser.py'>,
'email.header': <module 'email.header' from '/var/lang/lib/python3.6/email/header.py'>,
'email.iterators': <module 'email.iterators' from '/var/lang/lib/python3.6/email/iterators.py'>,
'email.message': <module 'email.message' from '/var/lang/lib/python3.6/email/message.py'>,
'email.parser': <module 'email.parser' from '/var/lang/lib/python3.6/email/parser.py'>,
'email.quoprimime': <module 'email.quoprimime' from '/var/lang/lib/python3.6/email/quoprimime.py'>,
'email.utils': <module 'email.utils' from '/var/lang/lib/python3.6/email/utils.py'>,
'encodings': <module 'encodings' from '/var/lang/lib/python3.6/encodings/__init__.py'>,
'encodings.aliases': <module 'encodings.aliases' from '/var/lang/lib/python3.6/encodings/aliases.py'>,
'encodings.latin_1': <module 'encodings.latin_1' from '/var/lang/lib/python3.6/encodings/latin_1.py'>,
'encodings.utf_8': <module 'encodings.utf_8' from '/var/lang/lib/python3.6/encodings/utf_8.py'>,
'enum': <module 'enum' from '/var/lang/lib/python3.6/enum.py'>,
'errno': <module 'errno' (built-in)>,
'fnmatch': <module 'fnmatch' from '/var/lang/lib/python3.6/fnmatch.py'>,
'functools': <module 'functools' from '/var/lang/lib/python3.6/functools.py'>,
'genericpath': <module 'genericpath' from '/var/lang/lib/python3.6/genericpath.py'>,
'gettext': <module 'gettext' from '/var/lang/lib/python3.6/gettext.py'>,
'grp': <module 'grp' from '/var/lang/lib/python3.6/lib-dynload/grp.cpython-36m-x86_64-linux-gnu.so'>,
'hashlib': <module 'hashlib' from '/var/lang/lib/python3.6/hashlib.py'>,
'heapq': <module 'heapq' from '/var/lang/lib/python3.6/heapq.py'>,
'html': <module 'html' from '/var/lang/lib/python3.6/html/__init__.py'>,
'html.entities': <module 'html.entities' from '/var/lang/lib/python3.6/html/entities.py'>,
'http': <module 'http' from '/var/lang/lib/python3.6/http/__init__.py'>,
'http.client': <module 'http.client' from '/var/lang/lib/python3.6/http/client.py'>,
'http.server': <module 'http.server' from '/var/lang/lib/python3.6/http/server.py'>,
'imp': <module 'imp' from '/var/lang/lib/python3.6/imp.py'>,
'importlib': <module 'importlib' from '/var/lang/lib/python3.6/importlib/__init__.py'>,
'importlib._bootstrap': <module 'importlib._bootstrap' (frozen)>,
'importlib._bootstrap_external': <module 'importlib._bootstrap_external' (frozen)>,
'importlib.abc': <module 'importlib.abc' from '/var/lang/lib/python3.6/importlib/abc.py'>,
'importlib.machinery': <module 'importlib.machinery' from '/var/lang/lib/python3.6/importlib/machinery.py'>,
'importlib.util': <module 'importlib.util' from '/var/lang/lib/python3.6/importlib/util.py'>,
'io': <module 'io' from '/var/lang/lib/python3.6/io.py'>,
'ipaddress': <module 'ipaddress' from '/var/lang/lib/python3.6/ipaddress.py'>,
'itertools': <module 'itertools' (built-in)>,
'json': <module 'json' from '/var/lang/lib/python3.6/json/__init__.py'>,
'json.decoder': <module 'json.decoder' from '/var/lang/lib/python3.6/json/decoder.py'>,
'json.encoder': <module 'json.encoder' from '/var/lang/lib/python3.6/json/encoder.py'>,
'json.scanner': <module 'json.scanner' from '/var/lang/lib/python3.6/json/scanner.py'>,
'keyword': <module 'keyword' from '/var/lang/lib/python3.6/keyword.py'>,
'linecache': <module 'linecache' from '/var/lang/lib/python3.6/linecache.py'>,
'locale': <module 'locale' from '/var/lang/lib/python3.6/locale.py'>,
'logging': <module 'logging' from '/var/lang/lib/python3.6/logging/__init__.py'>,
'lzma': <module 'lzma' from '/var/lang/lib/python3.6/lzma.py'>,
'main': <module 'main' from '/var/task/main.py'>,
'marshal': <module 'marshal' (built-in)>,
'math': <module 'math' from '/var/lang/lib/python3.6/lib-dynload/math.cpython-36m-x86_64-linux-gnu.so'>,
'mimetypes': <module 'mimetypes' from '/var/lang/lib/python3.6/mimetypes.py'>,
'numbers': <module 'numbers' from '/var/lang/lib/python3.6/numbers.py'>,
'operator': <module 'operator' from '/var/lang/lib/python3.6/operator.py'>,
'os': <module 'os' from '/var/lang/lib/python3.6/os.py'>,
'os.path': <module 'posixpath' from '/var/lang/lib/python3.6/posixpath.py'>,
'platform': <module 'platform' from '/var/lang/lib/python3.6/platform.py'>,
'posix': <module 'posix' (built-in)>,
'posixpath': <module 'posixpath' from '/var/lang/lib/python3.6/posixpath.py'>,
'pprint': <module 'pprint' from '/var/lang/lib/python3.6/pprint.py'>,
'pwd': <module 'pwd' (built-in)>,
'quopri': <module 'quopri' from '/var/lang/lib/python3.6/quopri.py'>,
'random': <module 'random' from '/var/lang/lib/python3.6/random.py'>,
're': <module 're' from '/var/lang/lib/python3.6/re.py'>,
'reprlib': <module 'reprlib' from '/var/lang/lib/python3.6/reprlib.py'>,
'runtime': <module 'runtime' from '/var/runtime/awslambda/runtime.cpython-36m-x86_64-linux-gnu.so'>,
'select': <module 'select' from '/var/lang/lib/python3.6/lib-dynload/select.cpython-36m-x86_64-linux-gnu.so'>,
'selectors': <module 'selectors' from '/var/lang/lib/python3.6/selectors.py'>,
'shutil': <module 'shutil' from '/var/lang/lib/python3.6/shutil.py'>,
'signal': <module 'signal' from '/var/lang/lib/python3.6/signal.py'>,
'site': <module 'site' from '/var/lang/lib/python3.6/site.py'>,
'socket': <module 'socket' from '/var/lang/lib/python3.6/socket.py'>,
'socketserver': <module 'socketserver' from '/var/lang/lib/python3.6/socketserver.py'>,
'sre_compile': <module 'sre_compile' from '/var/lang/lib/python3.6/sre_compile.py'>,
'sre_constants': <module 'sre_constants' from '/var/lang/lib/python3.6/sre_constants.py'>,
'sre_parse': <module 'sre_parse' from '/var/lang/lib/python3.6/sre_parse.py'>,
'ssl': <module 'ssl' from '/var/lang/lib/python3.6/ssl.py'>,
'stat': <module 'stat' from '/var/lang/lib/python3.6/stat.py'>,
'string': <module 'string' from '/var/lang/lib/python3.6/string.py'>,
'struct': <module 'struct' from '/var/lang/lib/python3.6/struct.py'>,
'subprocess': <module 'subprocess' from '/var/lang/lib/python3.6/subprocess.py'>,
'sys': <module 'sys' (built-in)>,
'sysconfig': <module 'sysconfig' from '/var/lang/lib/python3.6/sysconfig.py'>,
'tempfile': <module 'tempfile' from '/var/lang/lib/python3.6/tempfile.py'>,
'textwrap': <module 'textwrap' from '/var/lang/lib/python3.6/textwrap.py'>,
'threading': <module 'threading' from '/var/lang/lib/python3.6/threading.py'>,
'time': <module 'time' (built-in)>,
'token': <module 'token' from '/var/lang/lib/python3.6/token.py'>,
'tokenize': <module 'tokenize' from '/var/lang/lib/python3.6/tokenize.py'>,
'traceback': <module 'traceback' from '/var/lang/lib/python3.6/traceback.py'>,
'types': <module 'types' from '/var/lang/lib/python3.6/types.py'>,
'urllib': <module 'urllib' from '/var/lang/lib/python3.6/urllib/__init__.py'>,
'urllib.error': <module 'urllib.error' from '/var/lang/lib/python3.6/urllib/error.py'>,
'urllib.parse': <module 'urllib.parse' from '/var/lang/lib/python3.6/urllib/parse.py'>,
'urllib.request': <module 'urllib.request' from '/var/lang/lib/python3.6/urllib/request.py'>,
'urllib.response': <module 'urllib.response' from '/var/lang/lib/python3.6/urllib/response.py'>,
'uu': <module 'uu' from '/var/lang/lib/python3.6/uu.py'>,
'warnings': <module 'warnings' from '/var/lang/lib/python3.6/warnings.py'>,
'weakref': <module 'weakref' from '/var/lang/lib/python3.6/weakref.py'>,
'wsgi': <module 'wsgi' from '/var/runtime/awslambda/wsgi.py'>,
'wsgiref': <module 'wsgiref' from '/var/lang/lib/python3.6/wsgiref/__init__.py'>,
'wsgiref.handlers': <module 'wsgiref.handlers' from '/var/lang/lib/python3.6/wsgiref/handlers.py'>,
'wsgiref.headers': <module 'wsgiref.headers' from '/var/lang/lib/python3.6/wsgiref/headers.py'>,
'wsgiref.simple_server': <module 'wsgiref.simple_server' from '/var/lang/lib/python3.6/wsgiref/simple_server.py'>,
'wsgiref.util': <module 'wsgiref.util' from '/var/lang/lib/python3.6/wsgiref/util.py'>,
'zipimport': <module 'zipimport' (built-in)>,
'zlib': <module 'zlib' from '/var/lang/lib/python3.6/lib-dynload/zlib.cpython-36m-x86_64-linux-gnu.so'>}
/var/task/main.py:8: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. Please monkey-patch earlier. See https://github.com/gevent/gevent/issues/1016
gevent.monkey.patch_all()

junsk1 added a commit to CSCfi/metax-api that referenced this issue Jun 4, 2018
commit d9db33c
Merge: 71b3fc0 6d08730
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Mon Jun 4 10:28:22 2018 +0300

    Merge pull request #271 from CSCfi/CSCMETAX-280

    CSCMETAX-280:[FIX] proper handling of language field data.

commit 6d08730
Merge: 70cb0ea 71b3fc0
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Mon Jun 4 10:05:03 2018 +0300

    Merge branch 'test' into CSCMETAX-280

commit 70cb0ea
Merge: 8106f62 3a4ffdf
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Mon Jun 4 09:56:29 2018 +0300

    Merge branch 'CSCMETAX-280' of github.com:CSCfi/metax-api into CSCMETAX-280

commit 8106f62
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Mon Jun 4 09:38:10 2018 +0300

    CSCMETAX-280:[FIX] proper handling of language field data.

commit 3a4ffdf
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Mon Jun 4 09:38:10 2018 +0300

    CSCMETAX-280:[FIX] proper handling of language field data.

commit 71b3fc0
Merge: 7544057 4a7c1e5
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Fri Jun 1 16:41:04 2018 +0300

    Merge pull request #270 from CSCfi/CSCMETAX-280

    CSCMETAX-280:[ADD] datacatalog harvesting

commit 4a7c1e5
Merge: 71cf1e2 7544057
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Fri Jun 1 16:27:48 2018 +0300

    Merge branch 'test' into CSCMETAX-280

commit 71cf1e2
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Fri Jun 1 15:18:15 2018 +0300

    CSCMETAX-280:[FIX] according to review comments.

commit 73353bc
Author: Joonas Kesäniemi <joonas.kesaniemi@csc.fi>
Date:   Fri Jun 1 12:35:38 2018 +0300

    Update minimal_api.py

commit 6fceb94
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Fri Jun 1 12:23:44 2018 +0300

    CSCMETAX-280:[ADD] datacatalog harvesting

commit 7544057
Merge: 619b05f a0a4177
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Fri Jun 1 10:01:59 2018 +0300

    Merge pull request #269 from CSCfi/CSCMETAX-61-schema

    Etsim migration related schema changes (part2)

commit a0a4177
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Fri Jun 1 08:37:59 2018 +0300

    Etsim migration related schema changes (part2)

commit 619b05f
Merge: e630a33 5698ef8
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Thu May 31 09:53:05 2018 +0300

    Merge pull request #268 from CSCfi/CSCMETAX-61-schema

    Schema changes required by the Etsin migration.

commit 5698ef8
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Thu May 31 09:33:11 2018 +0300

    Schema changes required by the Etsin migration.

commit e630a33
Merge: 3cd96f4 68c329a
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 18:36:03 2018 +0300

    Merge pull request #264 from CSCfi/CSCMETAX-394-remove-sensitive-data-in-oai-pmh

    CSCMETAX-394: [ADD] Remove sensitive fields (email, phone, telephone)…

commit 68c329a
Merge: f27ada1 3cd96f4
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 17:30:21 2018 +0300

    Merge branch 'test' into CSCMETAX-394-remove-sensitive-data-in-oai-pmh

commit 3cd96f4
Merge: 2e75cb6 840679f
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 17:00:43 2018 +0300

    Merge pull request #267 from CSCfi/CSCMETAX-408-begin-storing-django-db-migration-files

    CSCMETAX-408: [ADD] Remove exclusion of migrations/ directory from .g…

commit 840679f
Merge: ac84393 2e75cb6
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 16:37:22 2018 +0300

    Merge branch 'test' into CSCMETAX-408-begin-storing-django-db-migration-files

commit ac84393
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Wed May 30 16:12:16 2018 +0300

    CSCMETAX-408: [ADD] Remove exclusion of migrations/ directory from .gitignore. Generate first migration files. Fix .flake8 to ignore migrations/ directory since there are files that are autogenerated

commit 2e75cb6
Merge: a7d893a 253f3f4
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Wed May 30 14:38:18 2018 +0300

    Merge pull request #265 from CSCfi/CSCMETAX-61-load-initial-data-fix

    CSCMETAX-61: [FIX] Try a fix to an error in initial data loading duri…

commit 253f3f4
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Wed May 30 14:37:40 2018 +0300

    CSCMETAX-61: [FIX] Try a fix to an error in initial data loading during travis deployment

commit f27ada1
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Wed May 30 14:24:31 2018 +0300

    CSCMETAX-394: [FIX] Uncomment the part that does the actual cleaning... In tests, search for known sensitive values instead of field names

commit bb654a6
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Wed May 30 13:42:27 2018 +0300

    CSCMETAX-394: [ADD] Remove sensitive fields (email, phone, telephone) from OAI-PMH api outputs

commit a7d893a
Merge: 92a4b96 d8fad2e
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 12:22:52 2018 +0300

    Merge pull request #263 from CSCfi/CSCMETAX-395-add-fields-params-for-datasets-pid-files-api

    CSCMETAX-395: [FIX] Datasets api /datasets/pid/files now also support…

commit d8fad2e
Merge: 019542d 92a4b96
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 12:05:30 2018 +0300

    Merge branch 'test' into CSCMETAX-395-add-fields-params-for-datasets-pid-files-api

commit 92a4b96
Merge: 8a816a2 f8cec67
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Wed May 30 12:02:02 2018 +0300

    Merge pull request #262 from CSCfi/CSCMETAX-400-allow-etsin-pid-override

    CSCMETAX-400: [ADD] Datasets api: Add query param ?migration_override…

commit 019542d
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Wed May 30 11:43:16 2018 +0300

    CSCMETAX-395: [FIX] Datasets api /datasets/pid/files now also supports ?file_fields=x,y,z parameter

commit f8cec67
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Tue May 29 16:08:17 2018 +0300

    CSCMETAX-400: [ADD] Datasets api: Add query param ?migration_override=bool which enables passing a custom preferred_identifier when creating datasets

commit 8a816a2
Merge: 224efb6 04348f4
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Tue May 29 13:53:10 2018 +0300

    Merge pull request #261 from CSCfi/CSCMETAX-61-change-travis-deploy-user

    CSCMETAX-61: [REF] Change Travis deploy user

commit 04348f4
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Tue May 29 13:43:43 2018 +0300

    CSCMETAX-61: [REF] Change Travis deploy user

commit 224efb6
Merge: a46bc27 daf89b4
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Tue May 29 12:25:43 2018 +0300

    Merge pull request #260 from CSCfi/CSCMETAX-398-allow-file-uptade-from-0-to-n

    CSCMETAX-398: [ADD] Datasets api: Allow the first addition of files t…

commit daf89b4
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Tue May 29 12:13:35 2018 +0300

    CSCMETAX-398: [ADD] Datasets api: Allow the first addition of files to an empty dataset to occur without creating a new dataset version (update from 0 files to N files)

commit a46bc27
Merge: 2fbcd7c 934f759
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Tue May 29 10:30:00 2018 +0300

    Merge pull request #259 from CSCfi/CSCMETAX-407-metadata-owner-org-filter

    CSCMETAX-407: [ADD] Query parameter to filter datasets by field metad…

commit 934f759
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Tue May 29 09:29:57 2018 +0300

    CSCMETAX-407: [ADD] Query parameter to filter datasets by field metadata_owner_org

commit 2fbcd7c
Merge: be8d86c c535c71
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Mon May 28 17:33:49 2018 +0300

    Merge pull request #258 from CSCfi/CSCMETAX-394-remove-sensitive-fields

    CSCMETAX-394: Remove sensitive fields from datasets apis

commit c535c71
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Mon May 28 16:48:54 2018 +0300

    CSCMETAX-61: [FIX] Restrict /datasets/pid/files from public

commit 64a626e
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Mon May 28 16:48:15 2018 +0300

    CSCMETAX-394: [ADD] Remove sensitive fields from datasets apis

commit be8d86c
Merge: 2c1a726 679fa92
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Mon May 28 15:04:03 2018 +0300

    Merge pull request #257 from CSCfi/CSCMETAX-359-relation-entity-type-refdata

    CSCMETAX-359: [ADD] research_dataset.relation.entity.type value is au…

commit 679fa92
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Mon May 28 14:54:04 2018 +0300

    CSCMETAX-359: [ADD] research_dataset.relation.entity.type value is auto-populated from resource_type reference data, if given. Adjust test data and tests accordingly.

commit 2c1a726
Merge: addf26c 0fc52cb
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Mon May 28 09:44:26 2018 +0300

    Merge pull request #256 from CSCfi/CSCMETAX-401

    CSCMETAX-401:[ADD] more data to the oai_dc metadataformat output

commit 0fc52cb
Merge: 34e23f5 addf26c
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Fri May 25 13:02:05 2018 +0300

    Merge branch 'test' into CSCMETAX-401

commit addf26c
Merge: 2968d16 863d154
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Fri May 25 13:01:38 2018 +0300

    Merge pull request #255 from CSCfi/CSCMETAX-393-restrict-api-access

    CSCMETAX-393: [ADD] Restrict service access per api by reading app_config

commit 34e23f5
Author: Joonas Kesäniemi <joonas.kesaniemi@csc.fi>
Date:   Fri May 25 12:53:36 2018 +0300

    Update minimal_api.py

commit 156f492
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Fri May 25 12:45:28 2018 +0300

    CSCMETAX-401:[ADD] more data to the oai_dc metadataformat output

commit 863d154
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Fri May 25 12:23:35 2018 +0300

    CSCMETAX-393: [ADD] Add permission class ServicePermissions, which reads app_config and controls general read and write access for services per each api

commit 779543b
Author: Hannu Kamarainen <hannu.kamarainen@csc.fi>
Date:   Fri May 25 11:21:49 2018 +0300

    CSCMETAX-61: [REF] Refactor modifying the Request object in CommonViewSet to be more sensible

commit 2968d16
Merge: 900992d b82a9cb
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Thu May 24 13:19:21 2018 +0300

    Merge pull request #253 from CSCfi/CSCMETAX-379

    CSCMETAX-379:[ADD] special handling of syke datasets for urnresolver

commit b82a9cb
Author: Joonas Kesäniemi <joonas.kesaniemi@csc.fi>
Date:   Thu May 24 12:52:11 2018 +0300

    Update syke.py

commit 4c7b2cb
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Thu May 24 12:47:00 2018 +0300

    CSCMETAX-379:[ADD] special handling of syke datasets for urnresolver

commit 900992d
Merge: f5b31b3 8c2ab79
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Tue May 22 10:24:26 2018 +0300

    Merge pull request #252 from CSCfi/CSCMETAX-61-update-requirements

    CSCMETAX-61: [REF] Update requirements.txt. Brings about a warning ab…

commit 8c2ab79
Author: Juha-Matti Lehtinen <junnu.lehtinen@gmail.com>
Date:   Tue May 22 10:10:16 2018 +0300

    CSCMETAX-61: [REF] Update requirements.txt. Brings about a warning about gevent monkey-patching, but according to  gevent/gevent#1016 should not affect since we do not import gevent in the code.

commit f5b31b3
Merge: 82836c0 43f9fd3
Author: hannu40k <hannu40k@users.noreply.github.com>
Date:   Mon May 21 16:47:18 2018 +0300

    Merge pull request #251 from CSCfi/CSCMETAX-37

    Changed datacite output according to comments

commit 43f9fd3
Author: jkesanie <joonas.kesaniemi@csc.fi>
Date:   Mon May 21 15:34:49 2018 +0300

    Changed datacite output according to comments
junsk1 added a commit to CSCfi/metax-api that referenced this issue Jun 5, 2018
* Changed datacite output according to comments

* CSCMETAX-61: [REF] Update requirements.txt. Brings about a warning about gevent monkey-patching, but according to  gevent/gevent#1016 should not affect since we do not import gevent in the code.

* CSCMETAX-379:[ADD] special handling of syke datasets for urnresolver

* Update syke.py

* CSCMETAX-61: [REF] Refactor modifying the Request object in CommonViewSet to be more sensible

* CSCMETAX-393: [ADD] Add permission class ServicePermissions, which reads app_config and controls general read and write access for services per each api

* CSCMETAX-401:[ADD] more data to the oai_dc metadataformat output

* Update minimal_api.py

* CSCMETAX-359: [ADD] research_dataset.relation.entity.type value is auto-populated from resource_type reference data, if given. Adjust test data and tests accordingly.

* CSCMETAX-394: [ADD] Remove sensitive fields from datasets apis

* CSCMETAX-61: [FIX] Restrict /datasets/pid/files from public

* CSCMETAX-407: [ADD] Query parameter to filter datasets by field metadata_owner_org

* CSCMETAX-398: [ADD] Datasets api: Allow the first addition of files to an empty dataset to occur without creating a new dataset version (update from 0 files to N files)

* CSCMETAX-61: [REF] Change Travis deploy user

* CSCMETAX-400: [ADD] Datasets api: Add query param ?migration_override=bool which enables passing a custom preferred_identifier when creating datasets

* CSCMETAX-395: [FIX] Datasets api /datasets/pid/files now also supports ?file_fields=x,y,z parameter

* CSCMETAX-394: [ADD] Remove sensitive fields (email, phone, telephone) from OAI-PMH api outputs

* CSCMETAX-394: [FIX] Uncomment the part that does the actual cleaning... In tests, search for known sensitive values instead of field names

* CSCMETAX-61: [FIX] Try a fix to an error in initial data loading during travis deployment

* CSCMETAX-408: [ADD] Remove exclusion of migrations/ directory from .gitignore. Generate first migration files. Fix .flake8 to ignore migrations/ directory since there are files that are autogenerated

* Schema changes required by the Etsin migration.

* Etsim migration related schema changes (part2)

* CSCMETAX-280:[ADD] datacatalog harvesting

* Update minimal_api.py

* CSCMETAX-406: [REF] Update data catalog and dataset schemas

* CSCMETAX-280:[FIX] according to review comments.

* CSCMETAX-280:[FIX] proper handling of language field data.

* CSCMETAX-280:[FIX] proper handling of language field data.

* CSCMETAX-406: [REF] Update data catalog and dataset schemas

* CSCMETAX-406: [REF] Update test data to comform with latest schema changes (description field cardinality change, some other)

* CSCMETAX-406: [FIX] OAI-PMH tests after schema updates

* CSCMETAX-280:[ADD] limit for metadata prefixes for datacatalog set.

* CSCMETAX-406: [ADD] Update data catalog and production catalog schemas also
junsk1 added a commit to CSCfi/metax-api that referenced this issue Jun 5, 2018
* Changed datacite output according to comments

* CSCMETAX-61: [REF] Update requirements.txt. Brings about a warning about gevent monkey-patching, but according to  gevent/gevent#1016 should not affect since we do not import gevent in the code.

* CSCMETAX-379:[ADD] special handling of syke datasets for urnresolver

* Update syke.py

* CSCMETAX-61: [REF] Refactor modifying the Request object in CommonViewSet to be more sensible

* CSCMETAX-393: [ADD] Add permission class ServicePermissions, which reads app_config and controls general read and write access for services per each api

* CSCMETAX-401:[ADD] more data to the oai_dc metadataformat output

* Update minimal_api.py

* CSCMETAX-359: [ADD] research_dataset.relation.entity.type value is auto-populated from resource_type reference data, if given. Adjust test data and tests accordingly.

* CSCMETAX-394: [ADD] Remove sensitive fields from datasets apis

* CSCMETAX-61: [FIX] Restrict /datasets/pid/files from public

* CSCMETAX-407: [ADD] Query parameter to filter datasets by field metadata_owner_org

* CSCMETAX-398: [ADD] Datasets api: Allow the first addition of files to an empty dataset to occur without creating a new dataset version (update from 0 files to N files)

* CSCMETAX-61: [REF] Change Travis deploy user

* CSCMETAX-400: [ADD] Datasets api: Add query param ?migration_override=bool which enables passing a custom preferred_identifier when creating datasets

* CSCMETAX-395: [FIX] Datasets api /datasets/pid/files now also supports ?file_fields=x,y,z parameter

* CSCMETAX-394: [ADD] Remove sensitive fields (email, phone, telephone) from OAI-PMH api outputs

* CSCMETAX-394: [FIX] Uncomment the part that does the actual cleaning... In tests, search for known sensitive values instead of field names

* CSCMETAX-61: [FIX] Try a fix to an error in initial data loading during travis deployment

* CSCMETAX-408: [ADD] Remove exclusion of migrations/ directory from .gitignore. Generate first migration files. Fix .flake8 to ignore migrations/ directory since there are files that are autogenerated

* Schema changes required by the Etsin migration.

* Etsim migration related schema changes (part2)

* CSCMETAX-280:[ADD] datacatalog harvesting

* Update minimal_api.py

* CSCMETAX-406: [REF] Update data catalog and dataset schemas

* CSCMETAX-280:[FIX] according to review comments.

* CSCMETAX-280:[FIX] proper handling of language field data.

* CSCMETAX-280:[FIX] proper handling of language field data.

* CSCMETAX-406: [REF] Update data catalog and dataset schemas

* CSCMETAX-406: [REF] Update test data to comform with latest schema changes (description field cardinality change, some other)

* CSCMETAX-406: [FIX] OAI-PMH tests after schema updates

* CSCMETAX-280:[ADD] limit for metadata prefixes for datacatalog set.

* CSCMETAX-406: [ADD] Update data catalog and production catalog schemas also
palango added a commit to raiden-network/raiden-services that referenced this issue Feb 25, 2020
/home/circleci/project/tests/conftest.py:5: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See gevent/gevent#1016. Modules that had direct imports (NOT patched): ['urllib3.util.ssl_ (/home/circleci/project/venv/lib/python3.7/site-packages/urllib3/util/ssl_.py)', 'urllib3.util (/home/circleci/project/venv/lib/python3.7/site-packages/urllib3/util/__init__.py)'].
  monkey.patch_all(subprocess=False, thread=False)  # isort:skip # noqa
akaloti added a commit to atearjen/CookieTrack that referenced this issue Apr 6, 2020
Current error:

/home/aaronistheman/.local/lib/python3.6/site-packages/grequests.py:22: MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors, including RecursionError on Python 3.6. It may also silently lead to incorrect behaviour on Python 3.7. Please monkey-patch earlier. See gevent/gevent#1016. Modules that had direct imports (NOT patched): ['urllib3.util.ssl_ (/home/aaronistheman/.local/lib/python3.6/site-packages/urllib3/util/ssl_.py)', 'urllib3.util (/home/aaronistheman/.local/lib/python3.6/site-packages/urllib3/util/__init__.py)'].
  curious_george.patch_all(thread=False, select=False)
Traceback (most recent call last):
  File "web_scrap.py", line 125, in <module>
    main()
  File "web_scrap.py", line 25, in main
    proxy_pool, headers_pool = create_pools()
  File "web_scrap.py", line 58, in create_pools
    proxies = proxies_pool()
...
  File "/usr/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/usr/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  File "/usr/lib/python3.6/ssl.py", line 465, in options
    super(SSLContext, SSLContext).options.__set__(self, value)
  [Previous line repeated 324 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object
PinkDraconian added a commit to PinkDraconian/Rocket-League-Private-Match-Brute-Forcer that referenced this issue May 2, 2020
ethomas997 added a commit to ethomas997/RotorHazard that referenced this issue Sep 23, 2020
ethomas997 added a commit to ethomas997/RotorHazard that referenced this issue Sep 23, 2020
moylop260 added a commit to vauxoo-dev/odoo that referenced this issue Jan 15, 2021
Using py3.6 and gevent==1.1.2 the following error could be reproduced
in corner cases:

    File "/usr/lib/python3.6/ssl.py", line 485, in verify_mode
        super(SSLContext, SSLContext).verify_mode.__set__(self, value)
    File "/usr/lib/python3.6/ssl.py", line 485, in verify_mode
        super(SSLContext, SSLContext).verify_mode.__set__(self, value)
    File "/usr/lib/python3.6/ssl.py", line 485, in verify_mode
        super(SSLContext, SSLContext).verify_mode.__set__(self, value)
    [Previous line repeated 281 more times]
    RecursionError: maximum recursion depth exceeded

But using any version gevent>1.1.2 the issue is not reproduced
even gevent==1.2.0

The corner case to reproduced is the following:
 - Use py3.6
 - install gevent==1.1.2
 - Configure the reverse proxy
   - Use proxy e.g. nginx
   - `--longpolling-port`
   - `--workers>2`
 - Use Odoo>=12.0
 - Install and configure [sentry module of the OCA](https://github.com/OCA/server-tools/tree/12.0/sentry)
 - Reload the /web page 2 times
 - See the logger error of maximum recursion
 - Now, install gevent==1.2.0
 - Restart odoo-bin service
 - Reload the /web page 2 times again
 - See the logger and now it is not reproduced

The gevent 1.1.2 version was assigned to be used in python3.5
But maybe for python3.6 we need bump it like python3.7

Issues related:
 - OCA/server-tools#1499
 - gevent/gevent#1016
 - getsentry/sentry#3384
 - odoo#50861
   - It was another corner case using py3.7 but they rolling backed
     to python 3.5 but maybe it could be reproduced in py3.6 too
@dvf
Copy link

dvf commented Jul 30, 2021

Any chance we can re-open this?

@gevent gevent locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants