Breakpoint in Thread not working

42 views
Skip to first unread message

frgoo

unread,
May 3, 2025, 4:55:47 AMMay 3
to PyScripter
Hello.

I have the problem that breakpoints are not working for a new project whereas it works in another project. The difference is that the threads are this time created by a foreign module I use and not by my own code.
 
The most simple code to reproduce is as follows:

------

import wsgiserver

def my_app(environ, start_response):
   status = '200 OK'
   response_headers = [('Content-type','text/plain')]
   start_response(status, response_headers)
   return [b'WSGIserver is running!']

if __name__ == '__main__':
   server = wsgiserver.WSGIServer(my_app)
   server.start()

----

Before that of course you have to call "pip install WSGIserver" if you don't have the package already installed.

I also noticed that the pre-created threads of the thread pool are not visible from "Call Stack" in PyScripter

I tested with latest version of PyScripter and Python on Windows.

Any suggestions how this can be fixed ore worked arounr?

Thanks a lot.

PyScripter

unread,
May 3, 2025, 7:33:25 AMMay 3
to PyScripter
Currently, only threads that inherit from threading.Thread can be debugged.  I suspect that wsgiserver, uses threads created differently e.g. by _thread.start_new_thread(my_func, ()).
You can open an issue at  Issues · pyscripter/pyscripter to request support for other types of threads.

frgoo

unread,
May 3, 2025, 7:40:33 AMMay 3
to PyScripter
Thanks for your answer.

I just took a look at the source of wsgiserver but it seems that from what you described it should work then.

----

class WorkerThread(threading.Thread):

....

class ThreadPool(object):
    def start(self):
        for i in range(self.min):
            self._threads.append(WorkerThread(self.server))
        for worker in self._threads:
            worker.setName("CP Server " + worker.getName())
            worker.start()
        for worker in self._threads:
            while not worker.ready:
                time.sleep(.1)
----

Regards

frgoo

unread,
May 3, 2025, 8:08:22 AMMay 3
to PyScripter
Maybe I may ask for your help again?
With the following minimal program without any 3rd party components I'm still not able to trigger the breakpoint.
What I'm doing wrong or what else can be wrong?

------

class TestTheread(threading.Thread):
   def run(self):
      for i in range(3):
         time.sleep(3)


th = TestTheread()
th.start()
th.join()

-----

Thanks again.

frgoo

unread,
May 3, 2025, 8:40:31 AMMay 3
to PyScripter
Ok I just tried example from the blog regarding thread debugging but I'm still not able
to get the breakpoint to work.


So maybe I'm doing something fundamentally wrong or maybe something
in my environment got broken.

I appreaciate any suggestions what to try next.

Thanks a lot and kind regards

PyScripter

unread,
May 3, 2025, 8:44:04 AMMay 3
to PyScripter
Note that the code below works:

import threading
import time

def run():
  for i in range(3):
     time.sleep(1)
     print(i)

th = threading.Thread(target=run)

th.start()
th.join()

I have opened an new issue  Cannot debug thread subclassing threading.Thread · Issue #1401 · pyscripter/pyscripter for subclassing threading.Thread and overriding run.  This is probably a regression.

frgoo

unread,
May 3, 2025, 8:54:08 AMMay 3
to PyScripter
Ok the example code you posted last is also working here.
So seems indeed that there is a problem with subclassing Thread.

Thanks for taking the time looking into it and keeping up the great work.

Cheers.

PyScripter

unread,
May 3, 2025, 10:02:04 PMMay 3
to PyScripter
Just to let you know that the issue has been fixed and the fix will be available in the next release coming out soon.

frgoo

unread,
May 4, 2025, 2:08:20 PMMay 4
to PyScripter
That's great news.
Thanks again!
Reply all
Reply to author
Forward
0 new messages