Forums

Cannot Reload App "Your webapp took a long time to reload. It probably reloaded, but we were unable to check it."

Help please. I've been using PA for several weeks now but tonight find that I can no longer restart my application. It times out, and I cannot go anywhere in my hosted site. I've tried killing all my consoles but that didn't help--didn't think it would, really. Google isn't helping me much. Anyone else having problems? Is there an Admin on that can take a look? Thank you. Site was working fine one minute, then it just stopped. No major change to code.

Jason

It looks like something went wrong with your app that was preventing it from being properly cleared up when it was realoaded. That left a bunch of non-working processes lying around that were then preventing subsequent reloads. I have killed the processes and your app now reloads correctly. I'm not sure what might have caused this.

Thank you. I may have figured out what did. Looks like I'm having the same issue again after you killed the processes. Here is what I changed right before this issue started again.

*Original Line*
    db.engine.execute(text('DROP VIEW IF EXISTS vw_backlogs'))
    db.engine.execute(text('CREATE VIEW vw_backlogs AS SELECT * FROM product_backlog;'))
*Changed Line*
    db.session.execute(text('DROP VIEW IF EXISTS vw_backlogs'))
    db.session.execute(text('CREATE VIEW vw_backlogs AS SELECT * FROM product_backlog;'))

I'm trying to specify a database binding when I execute some raw SQL. I have a separate log database that I want to clear out at the start of my app.

I have my bindings setup like this:

SQLALCHEMY_BINDS = {
    'qops': SQLALCHEMY_DATABASE_URI,
    'qopslog': QOPS_DB_URI,
}

So in my line of code above I'm trying to figure out how to specify the 'qopslog' binding to execute against.

Do you think changing from engine to session might be causing the issue that you saw. It's the only change I made prior to causing the problem again. Do you happen to know how I can achieve this? If not, no worries and I'll continue to research (but won't try the session thing again). :)

If you can check and kill any processes again that would be most appreciated. Again, sorry for the trouble as I learn my way around Flask and Python.

Sincerely,

Jason

Tried to edit my last post to format the code lines better and now it's in moderation.

I also in my psql session tried to query that vw_backlog and it just hangs. I can CTRL+C out of it but if I query again it hangs still. So, I bet whatever is going on there is hanging up the application. Just more info as to the problem. Still not sure about exactly what I did or what's going on, though.

Jason

That seems like a good theory to start with. I don't know enough about your app and postgres to have a theory about what is going on. I would suggest some experimentation and documentation reading.

It doesn't look like you have any processes lying around like last time.

Hi Glenn,

I just tried again and I still cannot reload my application and hitting the web site times out. If it's not processes, is there anything else that you can check that might be causing this? Thank you.

Jason

I also tried that query in psql and it's still stuck. Is there any way to restart my PostgreSQL to clear that up or is this a shared PostgreSQL instance?

Jason

I just setup a local dev environment and tested my code change locally and had the same results. PostgreSQL instance hung when I tried to query that view. So, if you can restart my PostgreSQL instance I won't be trying that code again. :) Thank you.

Jason

No problem. I have restarted you postgres database for you.

Hi Glenn, I apologize. I hadn't yet uploaded my fixed code and ran it again. Just woke up, wasn't thinking clearly. ;) If I can get one more database reset like you just did I would appreciate it.

I've got my fixed code uploaded now, and I've tested it locally and see no issues with it. No database hangs, and the app restarts fine. I've figured a lot of things out in the past few days. :)

Thanks Glenn.

Jason

No problem. That's done.

I am also facing this issue, I am trying to create a simple web app with django (I am a beginner), But I am Facing this issue while reloading

I see that you asked about this on another forum thread, so I've answered there.

I cannot reload my webapp please help me

I cannot reload my webapp please assist no code change was done

We're having the exact same problem. Subscribed!

"There was a problem. See this help page for some debugging tips. If it keeps happening, please send us feedback."

Thanks for reporting. We had a problem with one of our servers, it's fixed now. Sorry for any inconvenience caused.

PLEASE HELP I cannot reload my webapp please assist no code change was done

Jhonas

@austindouglas what happens?

I was going to open another post... cause the original post is too old, but now I see some new posts about it. I also have a app, that I cannot reload. Can I, have some help, pls ?

EDIT: I've solved the issue, thank you

Hi! I'm having the same issue for the last few days. Would appreciate any help?

@muffinmunchies Does web app work after reload?

Hi,I cannot reload my app please can you help me ?

What errors do you see? Also -- have checked your server and error logs yet? (You'll find them linked on the Web page.)

I got error raise TemplateNotFound(template) jinja2.exceptions.TemplateNotFound: home.html from error logs and I couldn't fix that I also upload to my template folder include html docs.

@ataarslaner Looks like relative vs absolute path problem. How do you point to that template?

Hello, i've also run into this issue by trying to store data into my table. I am not exactly sure what caused it since i am new to coding but i am also using db.session. If someone more experienced can advice me how to store data into my table i would appreciate.

I receive up to 40 POST request at the same time every 5 min, and i would like to store them into my table. I also have 10 "worker" but i'm not sur how to use them right to not get them into conflict.

I try it with that

pool = QueuePool(creator=create_engine, pool_size=10, max_overflow=10) session = scoped_session(sessionmaker(bind=pool)) ... db.session.add(new_job) db.session.commit()

But it does not add anything to my table

What database are you trying to write to?

I am trying to write into my table "totodb" But first i need an admin to reload my webapp

db=SQLAlchemy()

db.init_app(app)

###########Creation de la table totodb
class Job(db.Model):
    __tablename__ = "totodb"
    id = db.Column(db.Integer, primary_key=True)
    key = db.Column(db.String(64))
    ticker = db.Column(db.String(64))
    timeframe = db.Column(db.String(64))
    price = db.Column(db.String(64))
    timestamp = db.Column(db.DateTime)

So i have 10 workers, and i tried to do some queue with 'pool and session', this crashed my webapp, and i was not able to reload it after

#pool = QueuePool(creator=create_engine, pool_size=10, max_overflow=10)
#session = scoped_session(sessionmaker(bind=pool))

# Create a global queue
q = queue.Queue()

@app.route(webhook_url, methods=['POST'])
 def worker():
    while True:
        data = q.get()
        try:
            if (data['key'] == "thisisnottherealpassword"):
                print("####### Signal received {0} - {1}".format(data["ticker"],data["timestamp"]))
                new_job = Job(key=data['key'], ticker=data['ticker'], timeframe=data['timeframe'],
                    price=data['price'], timestamp=datetime.datetime.now())
                #db.session.add(new_job)
                #db.session.commit()
                print("####### Signal mis dans totodb {0} - {1}".format(data["ticker"],data["timestamp"]))
            else:
                print('Pas bon key')
        finally:
            q.task_done()
            print('--->Finis du setup // finfin '+str(datetime.now()))
worker()

So after reloading my webapp, what is the best way for me to handle 40 POST request arriving at the same time every 5 min in purpose to screenshot a google page and send it to twitter? I have thougth about saving the data into a database and then trying to do work in async.

Web apps on PythonAnywhere are not made to handle long running tasks. Take a look at https://help.pythonanywhere.com/pages/AsyncInWebApps/

The reload error was caused by q=queue.Queue(), i just removed it and it was fine. I am looking for async in web apps thanks for the link