Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask app occasionally hanging

Tags:

python

flask

I've been working on a Flask app which handles SMS messages using Twilio, stores them in a database, and provides access to a frontend via JSONP GET requests. I've daemonized it using supervisord, which seems to be working pretty well, but every few days it starts to hang (i.e. all requests pend forever or time out) and I have to restart the process. (I've also tried simply running it with nohup, but same problem.) I was suspicious that sqlite3 was somehow blocking occasionally, but my most recent test was to write a request method which didn't involve database access, and that's timing out too. I'm incredibly puzzled -- hopefully you've seen something similar or know what might be causing this.

The relevant code can be found here, and it's currently running (and stalled, as of this post) on my VPS at mattnichols.net:6288

Thanks!

Update: do you think this could be an issue with Flask's dev server? I'd like to believe that wrapping my app with Tornado (or something similar) could solve the problem, but I've also run other things for much longer without problems using the dev server.

like image 576
man1 Avatar asked Nov 11 '12 17:11

man1


1 Answers

For the record, this seems to have been solved by running my app using Tornado instead of the Flask dev server. Wrapping my Flask code into a Tornado server was super easy once I decided to do so: consult http://flask.pocoo.org/docs/deploying/wsgi-standalone/#tornado if you find yourself in my same situation.

like image 116
man1 Avatar answered Oct 29 '22 14:10

man1