A simple API can be used to control debugging more closely, once you have imported wingdbstub.py the first time, as was describe. This is useful in cases where you want to be able to start and stop debugging on the fly several times during a debug run, for example to avoid debug overhead except within a small sub-section of your code. It can also be useful in embedded scripting environments, particularly in those that alter the thread state or discard and recreate the Python instance across invocations.
To use the API, you must first configure and import wingdbstub.py as described in section Importing the Debugger.
High-Level API
The wingdbstub.Ensure(require_connection=1, require_debugger=1) function may be used to ensure the debugger is running and connected to the IDE. If require_connection is true, ValueError will be raised if a connection to the IDE cannot be made. If require_debugger is true, ValueError will be raised if the debugger binaries cannot be found or the debugger cannot be started.
Low-Level API
After importing wingdbstub, the following calls may be made on wingdbstub.debugger to control the debugger:
Here is a simple usage example:
import wingdbstub a = 1 # This line is debugged wingdbstub.debugger.SuspendDebug() x = 1 # This is executed without debugging wingdbstub.debugger.ResumeDebug() y = 2 # This line is debugged
SuspendDebug() and ResumeDebug() can be called as many times as desired, and nested calls will be handled so that debugging is only resumed when the number of ResumeDebug() calls matches the number of SuspendDebug() calls.