How to enable post mortem debugging in pydev?

I want to force pydev to enter interactive console mode whenever my program raises an unhandled exception, but I cannot figure out how to do this. As he behaves now, an exception is reported and the process is interrupted immediately.

After some searching, I found this: http://sourceforge.net/tracker/index.php?func=detail&aid=3029746&group_id=85796&atid=577332 which suggests using pydevd.set_pm_excepthook ()

However, when I add

import pydevd
pydevd.set_pm_excepthook()

to my code, I get an exception:

This function is now replaced by GetGlobalDebugger().setExceptHook and is now controlled by the PyDev UI.')
DeprecationWarning: This function is now replaced by GetGlobalDebugger().setExceptHook and is now controlled by the PyDev UI.

But:

GetGlobalDebugger().setExceptHook()

It doesn't seem to work, GetGlobalDebugger () does not exist in the global namespace.

+5
source share
3 answers

... > pydev > " ".

+4

, , :

import pydevd
pydevd.GetGlobalDebugger().setExceptHook(Exception, True, False)

. , doc setExceptHook:

, ,          .

, .

    E.g.:
        set_pm_excepthook((IndexError, ValueError), True, True)

        or

        set_pm_excepthook(IndexError, True, False)

        if passed without a parameter, will break on any exception

    @param handle_exceptions: exception or tuple(exceptions)
        The exceptions that should be handled.

    @param break_on_uncaught bool
        Whether it should break on uncaught exceptions.

    @param break_on_caught: bool
        Whether it should break on caught exceptions.

, , pydev eclipse , .

+2

I would like to add to Fabio's answer that you should actually specify the types of exceptions that will be caught (a long column with a checkmark above "Pause processing of unhandled exceptions"). Otherwise, after an exception occurs, the main console will shut down independently, and the interactive console (under the main console) will not work (shows [Invalid frame]: select the frame to connect the console. When you enter something).

0
source

All Articles