[wingide-users] Re: Debugging internally started python processes

Edward Diener eldiener at tropicsoft.com
Thu Jul 22 11:45:22 MDT 2010


On 7/21/2010 9:53 AM, Wingware Support wrote:
> Edward Diener wrote:
>> I am trying to debug a script where python is being reinvoked using
>> os.system('someCommand'), where the 'someCommand is first 'python
>> someScript.py someParameters' on one line and is then 'someScript.py
>> someScriptParameters' in another line.
>>
>> How can I get the debugger to debug whatever Python scripts are being
>> invoked in this way from within a script which I am already debugging ?
>>
>> Do I need to follow the Advanced Debugging Topic | Debugging
>> Externally Launched Code topics ? If so, how can I setup these two
>> situations where I can debug into these os.system calls ? I do have
>> the ability to change the script I am trying to debug but I do not
>> want to do it, if possible, in such a way where I must change the
>> os.system calls into something else since that seems to be where the
>> problem lies I am trying to solve. Needless to say the script just
>> hangs somewhere in one of the scripts being called by the second of
>> the os.system calls and I am trying to find out why.
>
> The problem here, as you noticed, is that Wing can't debug into spawned
> sub-processes. The only solution would be to use wingdbstub as explained
> in the above-referenced manual chapter.
> However, the IDE currently only supports one active debug session at a
> time, a limitation you may run into. If you launch the first debug
> process from the IDE, then launch another instance of Wing and have it
> listen for debug connections, the second process should be able to
> import wingdbstub and connect to the second instance of Wing. If you
> have three or more processes, it gets a bit trickier in that you need to
> configure different IDE instances to listen on different debugger ports
> and have each sub-process use a different wingdbstub with matching
> configuration. Usually it's just easier to select one sub-process in
> that case and not debug all of them at the same time.
>
> Please let me know if this does not help.

I am not sure how this debugging is meant to work and I do not believe 
the documentation makes it clear at all. Please provide examples in the 
future for debugging of embedded code which shows how this is supposed 
to work.

My situation is:

In first.py

os.system('second.py')

In second.py

Some code that I want to start debugging.

Do I put the wingdbstub.py and the wingdebugpw files in the directory 
where second.py exists and then an 'import wingdbstub' at the beginning 
of second.py ? Or does the wingdbstub.py and the wingdebugpw files go in 
the directory where first.py exists and then an 'import wingdbstub' goes 
before 'os.system('second.py')' ? It seems the first choice above is 
probably correct but your doc does not make this obvious. To debug both 
first.py and second.py do I open the Wing IDE twice with the appropriate 
source files in the project with their breakpoints and then start 
debugging first.py and somehow the second IDE instance stops at the 
appropriate breakpoing after the os.system('second.py') triggers ? If I 
am only concerned with debugging second.py do I just execute first.py ( 
or python first.py ) and an IDE instance,equivalent to the second one 
above, stops at the appropriate breakpoing after the 
os.system('second.py') triggers ?



More information about the wingide-users mailing list