Debugging multithreading

31 views
Skip to first unread message

frgoo

unread,
Aug 11, 2025, 5:48:57 AMAug 11
to PyScripter
Hello.

I have problems debugging multithreaded applications in PyScripter. Maybe anyone has a suggestion how to overcoms this.

When doing something like the following:

th = threading.Thread(target = worker)
th.start()
input('Press key to shutdown application')

I'm not able to debug the created thread cause the 'input' function creates a modal input window which is blocking the GUI of PyScripter and so also the debugger.

As a workaround I tried to replace 'input' by 'msvcrt.getch()' which does not create a input window however there seemsto be no way that any keypress reaches the application beeing debugged.

Then I tried to replace the 'input()' call by using a threading.Event :

ex = threading.Event()
ex.wait()

and setting the event 'ex' in a SIGTERM handler, however I found now way to send CTRL+C to the main thread when run from PyScripter.

All the above works when running outside of PyScripter.

Any suggestions for a workaround to make it possible to debug such application design with PyScripter?

Thanks a lot for additional ideas.

frgoo

unread,
Aug 12, 2025, 4:03:21 AMAug 12
to PyScripter
@PyScripter:

Thanks a lot for your email. The workaround you showed can indeed be used to circumvent the problem.

Kind Regards

frgoo

PyScripter

unread,
Sep 16, 2025, 12:40:24 PM (13 hours ago) Sep 16
to PyScripter
For the benefit of forum readers, I am repeating what I sent you by email:

 This is a bit tricky, but can be done.

Say you have the following: 

   Screenshot 2025-09-16 193623.png

With the breakpoints as in the picture you start debugging.

 The Calling Stack will look like this:

Screenshot 2025-09-16 193623.png  

Both threads are stopped.  The thread-1 is the active thread.

You can Step over (F8) or step into (F7) to  debug the thread.   When you are done debugging the thread you can press run (or switch to the main thread and step over) and the input dialog box will be displayed.  Pressing a key will eventually terminate the application.

Reply all
Reply to author
Forward
0 new messages