Skip to content

RecursionError: maximum recursion depth exceeded #92

Closed

Description

@teucer

With python-engineio = "3.1.0" I am getting RecursionError: maximum recursion depth exceeded:

 File "[...]\site-packages\urllib3\util\ssl_.py", line 281, in create_urllib3_context
    context.options |= options
  File "[...]\miniconda\envs\py36\lib\ssl.py", line 465, in options
     super(SSLContext, SSLContext).options.__set__(self, value)

Only two fixes so far:

  • Either pin python-engineio to 3.0.0
  • eventlet.monkey_patch(socket=False)

Details:

  • python 3.6.8
  • windows 7
  • conda 4.5.12
  • eventlet 0.24.1

Activity

  1. miguelgrinberg commented on Jan 16, 2019

    @miguelgrinberg
    Owner

    Can you share the complete stack trace please? The portion that you shared doesn't have enough context for me to understand what's going on.

  2. teucer commented on Jan 16, 2019

    @teucer
    Author
    ERROR:
    
     Exception on /auth/login [POST] [in c:\user\dev\venvs\flask_36\lib\site-packages\flask\app.py:1761]
    Traceback (most recent call last):
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask\app.py", line 2292, in wsgi_app
        response = self.full_dispatch_request()
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask\app.py", line 1815, in full_dispatch_request
        rv = self.handle_user_exception(e)
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
        return cors_after_request(app.make_response(f(*args, **kwargs)))
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask\app.py", line 1718, in handle_user_exception
        reraise(exc_type, exc_value, tb)
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask\_compat.py", line 35, in reraise
        raise value
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask\app.py", line 1813, in full_dispatch_request
        rv = self.dispatch_request()
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\flask\app.py", line 1799, in dispatch_request
        return self.view_functions[rule.endpoint](**req.view_args)
      
    File "C:\user\Dev\projects\vue_bare\app\backend\auth\views.py", line 14, in login
        if user is not None and user.verify_password(password):
      
    File "C:\user\Dev\projects\vue_bare\app\backend\models.py", line 69, in verify_password
        return check_page_login(self.username, password)
      
    File "C:\user\Dev\projects\vue_bare\app\backend\authenticate.py", line 13, in check_page_login
        r = s.get(url_page, auth=(username, password))
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\requests\sessions.py", line 546, in get
        return self.request('GET', url, **kwargs)
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\requests\sessions.py", line 533, in request
        resp = self.send(prep, **send_kwargs)
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\requests\sessions.py", line 646, in send
        r = adapter.send(request, **kwargs)
     
    File "c:\user\dev\venvs\flask_36\lib\site-packages\requests\adapters.py", line 449, in send
        timeout=timeout
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\urllib3\connectionpool.py", line 600, in urlopen
        chunked=chunked)
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\urllib3\connectionpool.py", line 343, in _make_request
        self._validate_conn(conn)
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\urllib3\connectionpool.py", line 839, in _validate_conn
        conn.connect()
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\urllib3\connection.py", line 332, in connect
        cert_reqs=resolve_cert_reqs(self.cert_reqs),
      
    File "c:\user\dev\venvs\flask_36\lib\site-packages\urllib3\util\ssl_.py", line 281, in create_urllib3_context
        context.options |= options
      
    File "C:\user\Dev\apps\miniconda\envs\py36\lib\ssl.py", line 465, in options
        super(SSLContext, SSLContext).options.__set__(self, value)
      
    File "C:\user\Dev\apps\miniconda\envs\py36\lib\ssl.py", line 465, in options
        super(SSLContext, SSLContext).options.__set__(self, value)
      
    File "C:\user\Dev\apps\miniconda\envs\py36\lib\ssl.py", line 465, in options
        super(SSLContext, SSLContext).options.__set__(self, value)
      
    [Previous line repeated 304 more times]
    RecursionError: maximum recursion depth exceeded while calling a Python object
    
  3. miguelgrinberg commented on Jan 16, 2019

    @miguelgrinberg
    Owner

    This doesn't appear to be related to python-engineio, note that there isn't a single reference to it in your stack trace. On the other side, this issue regarding monkey patching too late looks related to your problem: gevent/gevent#1016.

  4. teucer commented on Jan 17, 2019

    @teucer
    Author

    Pinning the version of python-engineio solves the issue (?)

  5. miguelgrinberg commented on Jan 17, 2019

    @miguelgrinberg
    Owner

    @teucer did you look at the link I sent?

  6. teucer commented on Jan 17, 2019

    @teucer
    Author

    @miguelgrinberg yes I did have look. I believe that the issue is not with the order of the imports. The only thing that has changed is the version of python-engineio. The code is the same: it works with the old version and does not work with the new one.

  7. miguelgrinberg commented on Jan 17, 2019

    @miguelgrinberg
    Owner

    @teucer this error occurs with improper monkey patching. You seem to be fixated on the pinning, but that is not indicative that the problem is in this package, it just means that something that I changed now exposes this bug, which is probably in your application.

    For starters, you are not monkey patching socket, I now see. How do you expect requests to work without a monkey patched socket library?

  8. teucer commented on Jan 17, 2019

    @teucer
    Author

    Below is the beginning init.py of my flask app

    import logging
    import os
    import time
    
    import eventlet
    
    eventlet.monkey_patch()
    

    This is called from a run.py

    import subprocess
    import sys
    
    import click
    from flask_migrate import Migrate, upgrade
    
    from app import create_app, db
    
    app = create_app()
    migrate = Migrate(app, db)
    

    So far it was working...

  9. miguelgrinberg commented on Jan 17, 2019

    @miguelgrinberg
    Owner

    From http://eventlet.net/doc/patching.html#monkeypatching-the-standard-library:

    It is important to call monkey_patch() as early in the lifetime of the application as possible. Try to do it as one of the first lines in the main module.

  10. teucer commented on Jan 17, 2019

    @teucer
    Author

    modified run.py to have

    import eventlet
    eventlet.monkey_patch()
    

    as the first statement to no avail: I am getting the same error

  11. miguelgrinberg commented on Jan 17, 2019

    @miguelgrinberg
    Owner

    All the documented instances of this bug were proven to be due to a bad monkey patching, so I have to suspect you still have a problem there. Unless you can provide something I can use to debug this I do not know what else I can do to get to the bottom of this issue.

  12. teucer commented on Jan 17, 2019

    @teucer
    Author

    I think the recent updates might have exposed some bugs in eventlet, when I uninstall flask-socketio it works. Is there a changelog?

  13. miguelgrinberg commented on Jan 17, 2019

    @miguelgrinberg
    Owner

    You can look at the commit list: https://github.com/miguelgrinberg/python-engineio/commits/master. All releases are clearly marked with a dedicated commit.

  14. teucer commented on Jan 17, 2019

    @teucer
    Author

    Removing the lines

    import eventlet
    eventlet.monkey_patch()
    

    fixes the problem.

  15. miguelgrinberg commented on Jan 17, 2019

    @miguelgrinberg
    Owner

    It may seem as if the problem is fixed, but that is not the right solution. Without monkey patching your requests calls are going to be blocking.

  16. teucer commented on Jan 18, 2019

    @teucer
    Author

    I am deploying the app with gunicorn and eventlet workers. Could you please let me know where the calls would be blocking?

    PS: I am not using eventlet anywhere else in the code.

  17. miguelgrinberg commented on Jan 18, 2019

    @miguelgrinberg
    Owner

    Read up on the topic here: http://eventlet.net/doc/patching.html#greening-the-world

    The important concept is this:

    One of the challenges of writing a library like Eventlet is that the built-in networking libraries don’t natively support the sort of cooperative yielding that we need.

    You are using requests, which uses the built-in networking libraries in Python.

  18. royrusso commented on Oct 22, 2019

    @royrusso

    Sorry to reopen, but related: eventlet/eventlet#371

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions