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

LoggerWriter infinite recursion #252

Open
kzidane opened this issue Mar 8, 2021 · 3 comments
Open

LoggerWriter infinite recursion #252

kzidane opened this issue Mar 8, 2021 · 3 comments
Assignees
Labels

Comments

@kzidane
Copy link
Member

kzidane commented Mar 8, 2021

@brianyu28 and I looked a bit into this. When the CS50 library makes a Logger.debug() call (or any student code writes anything I imagine), that ends up calling LoggerWriter.write(), presumably because of how the output streams are being temporarily redirected when we enter the CheckRunner context. LoggerWriter.write() calls self.logger.log(), which writes to the "check50" logger, which we think tries to write to stdout or stderr, which causes LoggerWriter.write() to be called again and so on.

@cmlsharp
Copy link
Contributor

I can look into this if you send me some example code?

@kzidane
Copy link
Member Author

kzidane commented Mar 21, 2021

@cmlsharp

$ pip install check50==3.2.1

$ cat app.py
import flask

import cs50


app = flask.Flask(__name__)
db = cs50.SQL('sqlite:///foo.db')


@app.route("/")
def index():
    db.execute('select 1')
    return ""

$ cat check/__init__.py
import check50
import check50.flask

@check50.check()
def test_index():
    App().get_index().status(200)


class App(check50.flask.app):
    def __init__(self):
        super().__init__("app.py")

    def get_index(self):
        return self.get("/")

$ check50 --dev check
...
Results for check generated by check50 v3.2.1
:( test db execute
    application raised an exception (see the log for more details)
    sending GET request to /
    exception raised in application: RecursionError: maximum recursion depth exceeded while calling a Python object

@sealimousavi
Copy link

Is this still open?

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

No branches or pull requests

4 participants