Reputation: 1717
Just to be extremely clear, here's some initial information about my setup:
Platform: Google App Engine
Environment Type: Standard
Runtime: Python 3
Python Framework: Flask
Web Server: Gunicorn, 2 workers
It's a flask app running on GAE standard python3 runtime.
Relevant File Structure:
- api.py
- services/
---- HighLow.py
As you can hopefully see from the file structure, the main flask app file is api.py
.
api.py
then imports services/HighLow.py
Relevant Code From HighLow.py:
def get_today_for_user(self, uid):
#Connect to MySQL
conn = pymysql.connect(self.host, self.username, self.password, self.database, cursorclass=pymysql.cursors.DictCursor)
cursor = conn.cursor()
uid = bleach.clean(uid)
cursor.execute("SELECT * FROM highlows WHERE uid='{}' AND DATE(_timestamp) = CURDATE();")
highlow = cursor.fetchone()
conn.commit()
conn.close()
if highlow == None:
return {
"high":"",
"low":"",
"total_likes": 0,
"high_image": "",
"low_image": ""
}
return highlow
If you want to look at the full code for better context, you can view it on our GitHub repo: https://github.com/highlowapp/highlowbackend
The Problem:
This setup has been working fine for a while now, and I was perfectly happy with it. However, I recently started getting this error from GCP's Error Reporting:
File "/srv/services/HighLow.py", line 380: 'low_image': ""
at <module> (/srv/api.py:8)
at <module> (/srv/wsgi.py:1)
at import_app (/env/lib/python3.7/site-packages/gunicorn/util.py:350)
at load_wsgiapp (/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py:41)
at load (/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py:52)
at wsgi (/env/lib/python3.7/site-packages/gunicorn/app/base.py:67)
at load_wsgi (/env/lib/python3.7/site-packages/gunicorn/workers/base.py:138)
at init_process (/env/lib/python3.7/site-packages/gunicorn/workers/base.py:129)
at spawn_worker (/env/lib/python3.7/site-packages/gunicorn/arbiter.py:583)
This error confuses me for a couple of reasons:
'low_image': ""
. 'low_image': ""
, when in reality (you can verify this on the GitHub repository), it's: "low_image": ""
(with double quotes). I've also tried simply deleting the line, but the error continues to appear.I've tried deleting app engine's storage bucket and re-running gcloud app deploy
, but nothing has changed that error message at all.
My Question
Why am I getting this error message, and how do I fix it?
EDIT:
As I said above, I already tried deleting the staging
bucket, and that didn't work.
Also, I used the "source" tool with Stackdriver to verify that the code has been updated.
Finally, I tried creating a new App Engine app in a separate project, and the code worked...except that I had an identical error in my code (maybe I'm just forgetting commas now?), which made the same error occur in a different file.
So I updated the file, redeployed, and voila! my app works!
However, I need it to work in the current project, not the test project. I need a way to clear everything that GAE knows about anything, and start all over. Is there a way to do this? Or does someone know why I'm having problems in the first place?
Upvotes: 1
Views: 48
Reputation: 1717
Ok, I finally figured out a workaround, and thought I'd share for anyone else who encounters this issue.
You know how tech support people always tell you to try turning it off and then back on? Let me tell you, it works.
I went to App Engine -> Settings -> Disable Application
, and let it disable, and then re-enabled it with App Engine -> Settings -> Enable Application
.
I guess it just needed to "reboot".
Upvotes: 1