我使用Pycharm 4,flask为0.10.1,python为3.4
当我从pycharm内部运行一个flask应用程序时,如果我用:
app.run(debug=True)我的断点被忽略了。在谷歌搜索之后,我发现为了让PyCharm在断点处停止,我应该用以下命令运行flask:
app.run(debug=True, use_reloader=False)现在PyCharm可以正确地在断点处停止,但我错过了自动重新加载功能。
有没有办法让两者协同工作?
使用python2.7,这两件事都能正常工作
我向PyCharm报告了这一点:https://youtrack.jetbrains.com/issue/PY-13976
发布于 2014-12-04 02:06:35
问题是,使用use_reloader=True时,werkzeug应用程序是在主应用程序的单独(子)线程中启动的,而PyCharm无法正确处理断点,因为断点在线程启动时会丢失。
你可以试着关注这个帖子:http://forum.jetbrains.com/thread/PyCharm-776,但它看起来在这方面没有太多的进展。
我建议使用Python式的东西,比如pdb,例如:
@app.route('/<string:page>')
def main(page):
import pdb; pdb.set_trace() # This line actually stops application execution
# and starts Python debug shell in the console
# where you can examine current scope and continue
# normal code execution at any time.
# You can inject *any* code here.
# For example, if you type `print page` during pause,
# it will output content of "page" variable.
return render_template('index.html')https://stackoverflow.com/questions/27087315
复制相似问题