瓶应用程序偶尔悬挂 [英] Flask app occasionally hanging
问题描述
我一直在使用Twilio处理SMS消息的Flask应用程序,将它们存储在数据库中,并通过JSONP GET请求提供对前端的访问。我已经使用supervisord进行了守护进程,这似乎工作得很好,但是每隔几天它就开始挂起(即所有的请求永远存在或超时),我必须重新启动进程。 (我也试着简单地用nohup来运行它,但同样的问题。)我怀疑sqlite3是偶尔阻塞,但我最近的测试是写一个请求方法,不涉及数据库访问,这是超时太。我非常困惑 - 希望你已经看到类似的东西或知道可能导致这种情况。
相关的代码可以找到这里,它目前正在我的VPS上运行(和停滞,作为这篇文章)在 mattnichols.net:6288
谢谢!
更新:你认为这可能是Flask的开发服务器的问题?我想相信用Tornado(或类似的东西)包装我的应用程序可以解决这个问题,但是我也运行了其他的东西,没有使用dev服务器的问题。
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.
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.
这篇关于瓶应用程序偶尔悬挂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!