[wingide-users] Remote debugging works once

Wingware Support support at wingware.com
Thu Sep 4 12:55:55 MDT 2008


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