Stack Overflow [ 镜像 ]
Seems really strange… I need some more info to better diagnose the issue:
Open \plugins\org.python.pydev.debug\pysrc\pydevd_constants.py and change
DEBUG_TRACE_LEVEL = 3
DEBUG_TRACE_BREAKPOINTS = 3
run your use-case with the problem and add the output to your question…
Also, it could be that for some reason the debugging facility is reset in some library you use or in your code, so, do the following: in the same place that you’d put the breakpoint do:
print ‘current trace function’, sys.gettrace()
(note: when running in the debugger, it’d be expected that the trace function is something as: <bound method PyDB.trace_dispatch of <main.PyDB instance at 0x01D44878>> )
Also, please post which Python version you’re using.
Answer part 2:
The fact that sys.gettrace() returns None is probably the real issue… I know some external libraries which mess with it (i.e.:DecoratorTools – read: http://pydev.blogspot.com/2007/06/why-cant-pydev-debugger-work-with.html) and have even seen Python bugs and compiled extensions break it…
Still, the most common reason it breaks is probably because Python will silently disable the tracing (and thus the debugger) when a recursion throws a stack overflow error (i.e.: RuntimeError: maximum recursion depth exceeded).
You can probably put a breakpoint in the very beginning of your program and step in the debugger until it stops working.
Or maybe simpler is the following: Add the code below to the very beginning of your program and see how far it goes with the printing… The last thing printed is the code just before it broke (so, you could put a breakpoint at the last line printed knowing it should be the last line where it’d work) – note that if it’s a large program, printing may take a long time – it may even be faster printing to a file instead of a console (such as cmd, bash or eclipse) and later opening that file (just redirect the print from the example to a file).
def trace_func(frame, event, arg):
print 'Context: ', frame.f_code.co_name, ‘\tFile:’, frame.f_code.co_filename, ‘\tLine:’, frame.f_lineno, ‘\tEvent:’, event
If you still can’t figure it out, please post more information on the obtained results…
Note: a workaround until you don’t find the actual place is using:
on the place where you’d put the breakpoint – that way you’d have a breakpoint in code which should definitely work, as it’ll force setting the tracing facility at that point (it’s very similar to the remote debugging: http://pydev.org/manual_adv_remote_debugger.html except that as the debugger was already previously connected, you don’t really have to start the remote debugger, just do the settrace to emulate a breakpoint)