[wingide-users] Remote debugging works once

Mark A. Schmucker masc at rincon.com
Thu Sep 4 14:55:58 MDT 2008


Thank you everyone for the quick responses. Setting kEmbedded to 1 did the
trick. Now the connection spans multiple script invocations (just like the
comment in wingdbstub says).

I did oversimplify the code for the purposes of my email. In the real app
I'm calling PyInitialize and PyFinalize just once, not around every call to
Python.

Wing rocks!

-----Original Message-----
From: Wingware Support [mailto:support at wingware.com] 
Sent: Thursday, September 04, 2008 11:56 AM
To: Mark A. Schmucker
Cc: wingide-users at wingware.com
Subject: Re: [wingide-users] Remote debugging works once

Mark A. Schmucker wrote:
> Hi, I have a C++ application with an embedded Python interpreter that 
> imports a Python script. I'm using Wing's remote debugging capability 
> to debug the script. When I tell the app to import the script, my 
> breakpoint in the script gets hit- once. If I "continue" so it exits 
> the script, then tell my app to import the script again, the script 
> does get imported, but my breakpoint does not get hit.
>  
> If I restart the app it works again- once.
>  
> My first thought was that I need to reload() the script or something, 
> however if I modify the script between imports, the script's print 
> statements do reflect the changes. So I believe it is being reloaded 
> properly.
>  
> Both before and after the successful import, Wing says it is listening 
> for remote connections: "No debug process / listening for connections 
> on TCP/IP port 50010. Allowed hosts: 127.0.0.1" (and some other hosts 
> that I also listen to).
>  
> My code to import the script using the embedding interpreter is pretty 
> simple right now, and it seems to work, so I don't believe it's the 
> problem but will include it anyway:
>  
> PyInitialize();
> PyObject *str = PyString_FromString("__main__"); PyObject *main_module 
> = PyImport_Import(str); PyObject *main_dict = 
> PyModule_GetDict(main_module); FILE *fp = fopen("test.py", "rt"); 
> PyRun_File(fp, filename, main_dict, main_dict); fclose(fp); 
> PyFinalize();
>  
> Any ideas why my breakpoint only works once?

You probably need to change this so PyInitialize() is only called once at
startup and PyFinalize() only once before your C++ app exits.  Then also you
would need to set kEmbedded=1 (default is 0) in wingdbstub.py. That may
solve it.  If not, then if may be necessary to use the debugger API to drop
and reestablish the connection.  It would be similar to how it's done for
mod_python:  http://wingware.com/doc/howtos/mod_python

Hope that helps -- please let me know if not.

-- 

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com





More information about the wingide-users mailing list