check50 icon indicating copy to clipboard operation
check50 copied to clipboard

LoggerWriter infinite recursion

Open kzidane opened this issue 4 years ago • 3 comments

@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.

kzidane avatar Mar 08 '21 02:03 kzidane

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

cmlsharp avatar Mar 20 '21 20:03 cmlsharp

@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

kzidane avatar Mar 21 '21 14:03 kzidane

Is this still open?

sealimousavi avatar Oct 12 '21 13:10 sealimousavi