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

Why doesn't flask reload when I change my code? It should automatically reload my app #2127

Closed
rlam3 opened this issue Dec 28, 2016 · 11 comments

Comments

@rlam3
Copy link

rlam3 commented Dec 28, 2016

Why doesn't flask reload when I change my code? It should automatically reload my app.... Is flask-script now obsolete in 0.12 flask?

smurfix/flask-script#172

@untitaker
Copy link
Contributor

Yes it should. Please describe exactly what you do.

@rlam3
Copy link
Author

rlam3 commented Dec 28, 2016

@untitaker It used to be that I was managing how I do runserver via manage.py with flask-script. Now that since I've been wanting to upgrade to newer flask version 0.12... I'm a bit confused on why this is happening... Also I believe there is something holding back flask from actually being able to auto reload when any part of my code base changes... It doesn't automatically reload anymore... Is there something I can do about this in my development environment?

Also because of this change... Will this affect how uwsgi is implemented with supervisor? If so could you please point out where are the changes? Thanks!

In addition could you please let me know if application factory pattern of designing larger apps still work? Or what sort of modifications were made to this patter? Thanks!

@untitaker
Copy link
Contributor

Also I believe there is something holding back flask from actually being able to auto reload when any part of my code base changes

This would be an actual bug, but you still haven't described which exact steps you take, such that I can reproduce your issue.

There's a bunch of unrelated questions you additionally asked which I can't all answer. I have no experience with uwsgi, however I can't imagine that configuration with uwsgi changes.

The app factory pattern also still works. You would create a separate module that calls your factory at import time. We're looking at improving this experience.

In the future please ask those questions in the IRC channel or on stackoverflow. This is a bugtracker. Let's focus on the bug you reported.

@untitaker
Copy link
Contributor

(if you want to understand the bigger picture, take a look at https://www.youtube.com/watch?v=1ByQhAM5c1I)

@davidism
Copy link
Member

Nothing has changed about the application factory pattern or about how you would run a Flask app with uWSGI. Nothing should have changed about the reloader, either. Please include a minimal, complete, and verifiable example when reporting a bug.

@pertcode
Copy link

pertcode commented Jan 5, 2017

@rlam3 What version did you upgrade from? Was it 0.10.X or earlier? And by code, do you mean the .py files or the html files? If it's the html (templates), then is this problem the same as #1907 which was fixed in #1910 ?

In 0.11 and 0.12 auto-reloading of templates does not seem to work if app.jinja_env object is accessed before app.run() or manager.run().

For me, the problem manifests when I use Flask-Bootstrap:

For example, this causes the problem:

from flask import Flask, render_template
from flask_script import Manager
from flask_bootstrap import Bootstrap

app = Flask(__name__)

@app.route('/test')
def test():
return render_template('test.html')

manager = Manager(app)
bootstrap = Bootstrap(app)

if __name__ == '__main__':
manager.run()

If I edit test.html (which is just 1 line of plain text) then my changes do not take affect until server is restarted. If I remove flask_bootstrap then it works as expected.

BRGDS/Chris

@davidism davidism closed this as completed Jan 9, 2017
@varunagrawal
Copy link

Hi, I'm facing the same problem currently.

In my case, my template directory and static directory are custom locations that I am pointing to when I initialize my flask app. When I change either the template or the source files, the app fails to reload correctly.

Any suggestions how I might fix this?

@pepprseed
Copy link

I am also seeing this behavior.

Up until late 2017 we were on python2.7 and flask 0.10.1 running on centOS linux. Whenever I made a change to one of our application's python modules or jinja2 templates, flask detected it and automatically reloaded... and I could see the results of my change by refreshing the browser page (pointing at a :5000 url)

In late 2017 we upgraded to python3.6 and flask 0.12.2 running on the same centOS linux. Now when I change one of the application's python modules or jinja2 templates, flask still seems to detect it but when I refresh the browser page the change isn't there. I must now do a control-C and restart the flask application, and refresh the browser page, to see my change. This adds a lot of potential confusion to the development process.

I hope this issue can be isolated and fixed.

@nanomosfet
Copy link

Make sure you are setting FLASK_DEBUG=1.

@pepprseed
Copy link

pepprseed commented Jan 24, 2018 via email

@febin-george
Copy link

Has anybody found a solution to the server having to be restarted each time when used with Bootstrap as @pertcode mentioned in the comment above ?
With Python 2, it seems to work fine. I'm having trouble running it on Python 3.

@pallets pallets locked as off-topic and limited conversation to collaborators Jan 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants