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
the code you want to debug. Make sure that WINGHOME inside
wingdbstub.py is set to the full path of your Wing installation
or debugger installation.
- 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 by clicking
on the breakpoint margin to the left of the code in Wing, or with
the breakpoint items in the Debug menu.
- 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. When a
breakpoint is reached, Wing should come to the front and show the file where
the debugger has stopped. 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.
Sub-sections:
13.0.0.
Debugging Externally Launched Remote Code
13.0.1.
Externally Launched Process Behavior
13.0.2.
Debugging Embedded Python Code
13.0.3.
Debug Server Configuration
13.0.4.
Debugger API