PyCharm not debugging into new Thread
I'm using PyCharm Community Edition 2020.1.2 on Windows 10 and I try to debug a Python 3.7 Toga project, created with the BeeWare 'briefcase new' command. The app is set up as a module and I can debug into it, until I get to Toga.App.main_window.main_loop(). There, a new thread for the app execution is created and the app's main window is displayed.
The debugger stops there and waits for the main_loop() to end and no breakpoint in my app code has any effect. Then, when main_loop ends, debugging resumes. But I want to debug the newly created thread, because that is where my app code is actually executed. I would have expected to see the new Thread under 'Frames',so that I could change to this thread to continue debugging. But under 'Frames', I first only see 'MainThread' and when main_loop() is executed, there is nothing in 'Frames' anymore until I close the app's main window. Then, again, 'MainThread' is displayed.
This is the code executed in main_loop():
def main_loop(self):
thread = Threading.Thread(Threading.ThreadStart(self.run_app))
thread.SetApartmentState(Threading.ApartmentState.STA)
thread.Start()
thread.Join()
Debugging works fine for apps using tkinter for example. A colleague told me that Toga debugging is working on his Mac but he has the same problem under Windows.
Please help
Please sign in to leave a comment.
try putting :
PYDEVD_USE_CYTHON=NO;PYDEVD_USE_FRAME_EVAL=NO
in environment variables ... as suggested to me by support ... worked for me
I had issues with debugger not stopping in threaded code, but I resolved it by going to `File | Settings | Build, Execution, Deployment | Python Debugger` and un-ticking "Gevent compatible". Hope this helps
None of these suggestions seem to work for me with PyCharm 2023.3 (PY-233.11799.259, built on December 3, 2023) when running the debugger with Python spawning threads with breakpoints in them.
I am experiencing the same issue with PyCharm Pro. My app is not using any threading whatsoever. I tried debugging the same app on both macOS and Windows 10. On macOS, I can debug normally, but on Windows 10, PyCharm ignores my breakpoints.
pycharm pro debug is freezing when starting a new thread , using tkinter as GUI. 2020.1.4. It seems to be intermittent. I will submit a ticket
I would suggest trying 2020.2 first and then submit a ticket if the issue is still there.
https://www.jetbrains.com/pycharm/download
thanks, tried that , same behaviour. Simple example sent me by support works fine, so something specific to my code. what it is doing is creating a tkinter window to monnito progress of a job in the main thread (all that tkinter will allow) , then creating another thread to run the job in. on switching to that, everything freezes. I will continue dialog with support
I'm seeing the same thing on the latest build .
PyCharm 2020.2.3 (Professional Edition)
I used to be able to debug threads it seems since updating to 2020 I have had issues. This is very inconvenient and really need this working like it used to work.
For me was opposite it helped when I checked "Gevent compatible"
Scott Ballard please create a new request on YouTrack so we can investigate this one further
My problem was that I was working on pyqt, but then I switched to PySide. If you go to `File | Settings | Build, Execution, Deployment | Python Debugger`, please untick ‘PyQt Compatible’.
I had a similar issue with PyCharm 2023.3.3 (Community Edition). I was running a PyQt project with threads, and the breakpoints in my threads were not working. To fix this, I went to `File | Settings | Build, Execution, Deployment | Python Debugger` and changed the “PyQt compatible” dropdown from “Auto” to “PyQt5” since that's the version of PyQt that I was using in the project. Now the breakpoints work.