Flask app occasionally hanging


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


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.

11/11/2012 6:16:29 PM

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.

8/19/2014 5:44:18 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow