New debugger error since upgrading to 2021.2

I have a flask app, that spawns a separate process that also uses sqlalchemy to talk to the database. I created a debug configuration to call a script to start it. It always worked fine in PyCharm. And VsCode. And the command line. 

Upgraded to 2021.2, and now I get an error when I start it, the flask_sqlalchemy "'No application found. Either work inside a view function or push". 

Go back to 2021.13, and everything is fine. Everything still works fine in VSCode, cmd, etc. 

Any idea on what's changed? Sticking with 2021.13 for now. 

 

2 comments
Comment actions Permalink

Do you get the issue when running as well as when debugging? The only known issue with Flask in 2021.2 I recall is PY-49984

If it's reproduced when running without debugger, is it possible to provide minimal project sample so I could reproduce it locally?

0
Comment actions Permalink

No error when running, just when debugging. Debugging in VSCode and previous versions of PyCharm works just fine though. 

This is a pretty massive app that I inherited, I'm not sure I can boil it down to a test project. I'll give it a shot when I have some free time.

The basic structure is this - a flask project with a db, and a subclass of multiprocessing Process that is spawned off and also talks to the db. It is this secondary process that's failing, the first time it attempts to query the database. The actual web app works fine. 

The script that launches everything is basically this:

import sys 
from app import create_app, db
from app.models import check_db

print(sys.version)
app = create_app()
app.app_context().push()

@app.shell_context_processor
def make_shell_context():
return {'db': db, 'User': User}

@app.route('/')
def hello_world():
return 'Hello, World!'

if __name__ == "__main__":
# Start separate process
with app.app_context():
print("Check the db, and verify the integrity.")
check_db()
ins_obj = SeparateProcessSubclass()
ins_obj.start() # This fails in the run method on first db query

app.run(host="0.0.0.0", port=5080)

App context should exist, and everything works fine when executing, or running in other debuggers. It's just this new version that creates problems.

0

Please sign in to leave a comment.