Home > OS >  Eclipse 2022-03, -06 with Pydev ignores breakpoints in threads
Eclipse 2022-03, -06 with Pydev ignores breakpoints in threads

Time:07-15

I am trying to use the Pydev debugger for a multi-threaded application. Any breakpoints set in the threads are ignored and just stepped over. Setup: Eclipse 2022-03 or -06 with Python 3.6. Sample code:

from threading import Thread
from time import sleep


def myasync(f):
    
    def wrapper(*args, **kwargs):
        thr = Thread(target = f, args = args, kwargs = kwargs)
        thr.start()
        return thr
    return wrapper


@myasync
def dosomething():
    print('doing something')
    sleep(2)
    print('really busy doing more')   # set breakpoint here
    sleep(2)
    print('something done')


if __name__ == '__main__':
    res = dosomething()
    print(type(res))
    print(res)
    res.join()
    
    print('done')

Setting a breakpoint on the indicated line worked with Eclipse 2021-12 and before. Since then it gets ignored. Interestingly Eclipse About gives the same Pydev Version for 2022-06 and 2021-12 (9.3.0).

Solutions relying on pydevd like this or that do not work.

Using the manual debugger via import pdb; pdb.set_trace() does work, but is not a real option.

Any ideas how I get the Eclipse breakpoints working again?

EDIT: after Fabios comment

I am working on an OpenSuse 15.4. The logfile is:

0.17s - Using Cython speedups
0.02s - Greenlet version: 0.4.13
0.00s - Gevent version: 1.2.2
0.00s - Gevent install location: /usr/lib64/python3.6/site-packages/gevent/__init__.py
0.00s - Using GEVENT_SUPPORT: True
0.00s - Using GEVENT_SHOW_PAUSED_GREENLETS: False
0.00s - pydevd __file__: /usr/local/eclipse/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/pydevd.py
0.00s - Initial arguments: (['/usr/local/eclipse/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/pydevd.py', '--multiprocess', '--protocol-http', '--print-in-debugger-startup', '--vm_type', 'python', '--client', '127.0.0.1', '--port', '34907', '--file', '/home/map/wgproto/testpy/threaddebug.py'],)
0.00s - Current pid: 9323
0.00s - Executing file /home/map/wgproto/testpy/threaddebug.py
0.00s - arguments: (['/home/map/wgproto/testpy/threaddebug.py'],)
0.00s - pydevd: Use libraries filter: False

0.00s - IDE_PROJECT_ROOTS ['/home/map/wgproto/testpy']

0.00s - Collecting default library roots.
0.00s - LIBRARY_ROOTS ['/home/map/.local/lib/python3.6/site-packages', '/home/map/local/lib/python3/site-packages', '/usr/lib/python3.6/site-packages', '/usr/lib64/python3.6', '/usr/lib64/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages', '/usr/local/lib64/python3.6/site-packages']

0.00s - sending cmd (quoted-line) -->     CMD_SET_PROTOCOL 

0.00s - sending cmd (http) -->     CMD_SET_PROTOCOL 

0.00s - Connecting to 127.0.0.1:34907
0.00s - Connected.
0.00s - Applying patching to hide pydevd threads (Py3 version).
0.00s - debugger: received >>503    1   http<<

0.00s - Received command: CMD_SET_PROTOCOL 503  1   http

0.00s - sending cmd (http) -->     CMD_SET_PROTOCOL 

0.00s - debugger: received >>501    3   1.1 UNIX    ID<<

0.00s - Received command: CMD_VERSION 501   3   1.1 UNIX    ID

0.00s - sending cmd (http) -->          CMD_VERSION @@BUILD_NUMBER@@

0.00s - debugger: received >>162    5   {"debug":false,"force":false,"pathMappings":[]}<<

0.00s - Received command: CMD_SET_PATH_MAPPING_JSON 162 5   {"debug":false,"force":false,"pathMappings":[]}

0.00s - debugger: received >>111    7   0   python-line /home/map/wgproto/testpy/threaddebug.py 18  dosomething None    None<<

0.00s - Received command: CMD_SET_BREAK 111 7   0   python-line /home/map/wgproto/testpy/threaddebug.py 18  dosomething None    None

0.00s - Request for breakpoint in: /home/map/wgproto/testpy/threaddebug.py line: 18
0.00s - Breakpoint (after path translation) in: /home/map/wgproto/testpy/threaddebug.py line: 18
0.00s - Added breakpoint:/home/map/wgproto/testpy/threaddebug.py - line:18 - func_name:dosomething

0.00s - debugger: received >>161    9   {"break_on_uncaught":false,"break_on_user_caught":false,"break_on_caught":false,"skip_on_exceptions_thrown_in_same_context":false,"ignore_exceptions_thrown_in_lines_with_ignore_exception":true,"ignore_libraries":true,"exception_types":[]}<<

0.00s - Received command: CMD_SET_PY_EXCEPTION_JSON 161 9   {"break_on_uncaught":false,"break_on_user_caught":false,"break_on_caught":false,"skip_on_exceptions_thrown_in_same_context":false,"ignore_exceptions_thrown_in_lines_with_ignore_exception":true,"ignore_libraries":true,"exception_types":[]}

0.00s - debugger: received >>133    11  <<

0.00s - Received command: CMD_SET_PROPERTY_TRACE 133    11  

0.00s - debugger: received >>140    13  REPLACE:<<

0.00s - Received command: CMD_IGNORE_THROWN_EXCEPTION_AT 140    13  REPLACE:

0.00s - debugger: received >>126    15  DjangoExceptionBreak<<

0.00s - Received command: CMD_REMOVE_DJANGO_EXCEPTION_BREAK 126 15  DjangoExceptionBreak

0.00s - debugger: received >>123    17  jinja2-Exception<<

0.00s - Received command: CMD_REMOVE_EXCEPTION_BREAK 123    17  jinja2-Exception

0.00s - debugger: received >>141    19  true<<

0.00s - Received command: CMD_ENABLE_DONT_TRACE 141 19  true

0.00s - debugger: received >>146    21  CMD_SHOW_RETURN_VALUES  1<<

0.00s - Received command: CMD_SHOW_RETURN_VALUES 146    21  CMD_SHOW_RETURN_VALUES  1

0.00s - Show return values: True
0.00s - debugger: received >>101    23  <<

0.00s - Received command: CMD_RUN 101   23  

0.10s - sending cmd (http) -->    CMD_THREAD_CREATE <xml><thread name="MainThread" id="pid_9323_id_140279313850888" /></xml>

0.00s - Patching args: ['/bin/sh', '-c', 'uname -p 2> /dev/null']
0.00s - Process is not python, returning.
0.00s - sending cmd (http) -->  CMD_PROCESS_CREATED <process/>

0.01s - Successfully Loaded helper lib to set tracing to all threads.
4.01s - pydevd.stoptrace()
0.00s - PyDB.dispose_and_kill_all_pydevd_threads (called from: File "/usr/local/eclipse/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/pydevd.py", line 2976, in stoptrace)
0.00s - PyDB.dispose_and_kill_all_pydevd_threads (first call)
0.00s - PyDB.dispose_and_kill_all_pydevd_threads no commands being processed.
0.00s - PyDB.dispose_and_kill_all_pydevd_threads killing thread: <CheckAliveThread(pydevd.CheckAliveThread, started 140279193528064)>
0.00s - pydevd.CheckAliveThread received kill signal
0.00s - PyDB.dispose_and_kill_all_pydevd_threads killing thread: <ReaderThread(pydevd.Reader, started daemon 140279281846016)>
0.00s - pydevd.Reader received kill signal
0.00s - PyDB.dispose_and_kill_all_pydevd_threads killing thread: <PyDBCommandThread(pydevd.CommandThread, started daemon 140279201920768)>
0.00s - pydevd.CommandThread received kill signal
0.00s - PyDB.dispose_and_kill_all_pydevd_threads killing thread: <WriterThread(pydevd.Writer, started daemon 140279290238720)>
0.00s - pydevd.Writer received kill signal
0.00s - PyDB.dispose_and_kill_all_pydevd_threads waiting for pydb daemon threads to finish
0.00s - WriterThread: CMD_EXIT received
0.00s - WriterThread: exit
0.50s - The following pydb threads may not have finished correctly: pydevd.Reader
0.00s - PyDB.dispose_and_kill_all_pydevd_threads: finished

Immediately after line 89 Successfully Loaded helper lib to set tracing to all threads. comes a 4.01s - pydevd.stoptrace(). in line 90. I think that is where the debugging stops working. Any idea where that comes from?

Converting the 2021-12 workspace for testing this to a 2022-06 workspace I managed to run the test successfully (aka stopping at the breakpoint. But I am lost about why it won't work in my project workspace.

CodePudding user response:

The logs show you're using GEVENT_SUPPORT:True, yet your code doesn't refer to gevent... if you disable it, does it work?

i.e.: in Preferences > PyDev > Debug uncheck Gevent compatible debugging (or unset the GEVENT_SUPPORT environment variable if you're doing it through an environment variable setting).

  • Related