Debugging Externally Launched Code

Index of All Documentation » Wing Pro Reference Manual » Advanced Debugging Topics »


This section describes how to start debugging from a process that is not launched by Wing. Examples of debug code that is launched externally include web tasks running under a web server and embedded Python scripts running inside a larger application.

The following instructions can be used to start debugging in externally launched code that is running on the same machine as Wing:

  • Copy wingdbstub.py from the install directory listed in Wing's About box into the same directory as your debug program.
  • In some cases, you will also need to copy the file wingdebugpw from your User Settings Directory into the same directory as wingdbstub.py. This is needed when running the debug process as a different user or in a way that prevents the debug process from reading the wingdebugpw file from within your User Settings Directory.
  • At the point where you want debugging to begin, insert the following source code: import wingdbstub. If you are debugging code in an embedded Python instance, see the notes in Debugging Embedded Python Code.
  • Make sure the Wing preference Accept Debug Connections is turned on, to allow connection from external processes.
  • Set any required breakpoints in your Python source code.
  • Initiate the debug program from outside Wing in a way that causes it to import wingdbstub and reach a breakpoint or exception. You should see the status indicator in the lower left of the main Wing window change to yellow, red, or green, as described in Debugger Status. If no breakpoint or exception is reached, the program will run to completion, or you can use the Pause command in the Debug menu.

If you have problems making this work, try setting kLogFile variable in wingdbstub.py to log additional diagnostic information.

Section Contents