[wingide-users] Threads launched in a unit test always attach to the debugger when "Enable Passive Listen" is selected

Wingware Support support at wingware.com
Mon Oct 11 07:46:30 MDT 2010

Russell Warren wrote:
> I've recently started using wingdbstub to do some external debugging, 
> so I set the "Enable Passive Listen" option accordingly.  Now when I 
> "run" (not "debug") a unit test, my code has started stopping on 
> breakpoints that I have set.  In "run" mode this should not happen.
> After further investigation, the breakpoint is only being triggered if 
> it is within a thread that the unit test launched.  Breakpoints in the 
> main program are not triggered, as expected.
> Is there a way around this?  The code on the thread is not importing 
> wingdbstub.
> This happens in both Wing3 and Wing4 pro.
> On a related note, are there any issues importing wingdbstub in 
> something that will be run from within the IDE?  For example, is code 
> like below necessary?
> if __debug__:
>   if "wing" not in sys.argv[0].lower():
>     #code is not being run from within Wing
>     import wingdbstub
>     wingdbstub.kAttachPort = 50010

It must be importing wingdbstub for debugging to be started. You will 
probably need to isolate the import in some way so it does not occur 
when running your unit tests. You could do this either by moving it 
outside of the tests or adding conditional code, probably by inspecting 
sys.argv as you suggest, or possibly os.environ. If you don't know what 
code to use, just set a breakpoint on the line following "import 
wingdbstub" and use the Debug Probe to inspect the environment. This 
would also be the way to determine why the import is happening if you're 
not expecting it to.



Stephan Deibel
Wingware | Python IDE
Advancing Software Development


More information about the wingide-users mailing list