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

RecursionError: maximum recursion depth exceeded while calling a Python object #1531

Closed
Set4now opened this issue Feb 5, 2020 · 3 comments
Closed

Comments

@Set4now
Copy link

Set4now commented Feb 5, 2020

  • gevent version: 1.4.0
  • Python version: 3.6.9
  • Operating System: Red Hat Enterprise Linux Server release 5.3 (Tikanga)

current setup
nginx-gunicorn-flask

Description:

Am trying to run flask-socketIO with gevent and gunicorn
gunicorn -k gevent -c $1 app:app

cat app. py
from flask_socketio import SocketIO
app = Flask(__name__)
app.secret_key = """kljclkcdlskcmsdlkcmnyrandomstring"""
socketio = SocketIO(app)

if __name__ == '__main__':
    app.config['DEBUG'] = True

Gunicorn starts but throws exception:-
......
client_cert=new_config.client_cert)
client_cert=client_cert,
File "/python3.6/site-packages/botocore/httpsession.py", line 180, in init
self._manager = PoolManager(**self._get_pool_manager_kwargs())
File "python3.6/site-packages/botocore/httpsession.py", line 188, in _get_pool_manager_kwargs
'ssl_context': self._get_ssl_context(),
File "/lib/python3.6/site-packages/botocore/httpsession.py", line 197, in _get_ssl_context
return create_urllib3_context()
File "/lib/python3.6/site-packages/botocore/httpsession.py", line 72, in create_urllib3_context
context.options |= options
File "/python3.6/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.set(self, value)
File "/python3.6/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.set(self, value)
File "/python3.6/lib/python3.6/ssl.py", line 465, in options
super(SSLContext, SSLContext).options.set(self, value)
[Previous line repeated 310 more times]
RecursionError: maximum recursion depth exceeded while calling a Python object

@Set4now
Copy link
Author

Set4now commented Feb 5, 2020

I have seen people are talking about monkey patching order. Not sure where exactly i need to insert that

@jamadden
Copy link
Member

jamadden commented Feb 5, 2020

You must monkey-patch before importing anything else. gunicorn's default monkey patching is sometimes not enough and you need to do it sooner. Exactly how you do that will depend on your specific deployment scenario (we use a setuptools entry point). There's more discussion at benoitc/gunicorn#1566

Example entry point

Add a module:

# gevent_gunicorn.py
from gevent import monkey; monkey.patch_all()
import sys
from pkg_resources import load_entry_point


def main():
    sys.exit(
        load_entry_point('gunicorn', 'console_scripts', 'gunicorn')()
    )


if __name__ == '__main__':
    sys.exit(main())

And add the entry point in setup.py:

setup(…
    entry_points={
        'console_scripts': [
            "my_gunicorn=my.package.gevent_gunicorn:main",
        ],
    },
)

Then to launch, specify my_gunicorn <arguments> instead of gunicorn <arguments>.

@jamadden
Copy link
Member

Closing since there’s been no response.

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

2 participants