我像往常一样开始我的烧瓶应用程序(比如python myapp.py 127.0.0.1:5000) 但是在输出后它关闭了
* Running on http://127.0.0.1:5000/
* Restarting with reloader
太奇怪了。
使用了一些代码注释后,我在 model.py 中找到了debug=False
或不from flask.ext.sqlalchemy import SQLAlchemy
,可以防止烧瓶自行关闭。
我不知道该怎么做我需要调试模式调试和SQLAlchemy来构建我的模型。
要找出问题所在,我简化了我的应用很多。
好的,我使用pdb调试myapp并得到了这些:
root@yes:/home/xxx/yyy# python -m pdb myapp.py
> /home/xxx/yyy/myapp.py(4)<module>()
-> from flask import Flask
(Pdb) c
* Running on http://127.0.0.1:5000/
* Restarting with reloader
The program exited via sys.exit(). Exit status: -9
> /home/xxx/yyy/myapp.py(4)<module>()
-> from flask import Flask
(Pdb)
我进入pdb并且我获得了退出状态-9在supprocess.py中返回(行:1336)
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
_WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
_WEXITSTATUS=os.WEXITSTATUS):
# This method is called (indirectly) by __del__, so it cannot
# refer to anything outside of its local scope.
if _WIFSIGNALED(sts):
self.returncode = -_WTERMSIG(sts) # line:1336
elif _WIFEXITED(sts):
self.returncode = _WEXITSTATUS(sts)
else:
# Should never happen
raise RuntimeError("Unknown child exit status!")