Gre*_*Guy 6 python django debugging pycharm
我已将我的项目正确配置为manage.py
使用正确的设置在正确的位置运行。
我还在一个我确信正在执行的方法中设置了调试断点(我在那里放置了一条打印语句,它按预期执行)。断点未禁用或有条件:
当我点击“在调试模式下运行”按钮时,使用上面的运行配置(我确信它是相同的,因为它是我为该项目配置的唯一一个),这是我得到的控制台输出:
pydev debugger: process 38083 is connecting
Connected to pydev debugger (build 192.5728.105)
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
December 23, 2020 - 19:22:22
Django version 3.1.4, using settings 'FEArena.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)
当我尝试在 中放置断点时manage.py
,它按预期工作,在我点击“调试”按钮时触发。但是,在应用程序启动后,当我使用 REST 客户端触发上述方法(其中有断点的方法)时,断点不会触发,调试器也不会启动。我200 OK
在 REST 客户端中收到响应,但 PyCharm 不会在任何时候停止并执行调试器。
我查看了建议设置“Gevent 兼容调试”的其他答案(我没有,因为我使用的是社区版),并且我尝试删除.idea/
项目的文件夹,但这也没有解决问题。我不确定还有什么可能导致这种情况。我只是想调试我的程序。
我的 PyCharm 版本信息是
PyCharm 2019.2 (Community Edition)
Build #PC-192.5728.105, built on July 23, 2019
Runtime version: 11.0.3+12-b304.10 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 4029M
Cores: 8
Registry:
Non-Bundled Plugins: com.karateca.jstoolbox, mobi.hsz.idea.latex, net.seesharpsoft.intellij.plugins.csv, nl.rubensten.texifyidea, org.intellij.plugins.markdown
Run Code Online (Sandbox Code Playgroud)
可能导致断点未触发的原因是什么?如何修复此问题?我需要断点来调试程序的其他部分。
当我调用 executor.submit 时,我之前在 PyCharm 中遇到了类似的问题。我必须插入一行请求代码结果才能重新调用预期的调试行为。如果您的代码是线程化的,您可能希望从这里开始。
future = executor.submit(control, channel) # spawn a function control(channel)
print(f'Future result is: {future.result()}') # new line I had to add to enable debugging
Run Code Online (Sandbox Code Playgroud)
编辑:将链接添加到帮助我在 PyCharm 中实现类似行为的线程。 并发.futures.ThreadPoolExecutor不打印错误
归档时间: |
|
查看次数: |
1615 次 |
最近记录: |