[PyQt] /NewThread/, and Python stack in Visual Studio

Kevin Watters kevinwatters at gmail.com
Thu Jun 12 15:50:00 BST 2008

I noticed /NewThread/ on QThread and QRunnable in the PyQT source-- and
a peek at the source code shows SIP creating thread local structures for
pending objects.

My app creates threads, but only through Python's threading module.

Do I need to use /NewThread/, or call something like api_new_thread/
api_end_thread manually?  I do need to call back to one specific
function wrapped by SIP that allows for cross thread communication, and
I've noticed that I'm getting sporadic crashes where the bottom of the
stack is the worker thread initialization.

...Which brings me to question #2: does anyone know how to get the
names of functions in the current Python stack visible in 
Visual Studio's debugger? The "Call Stack" tab isn't very helpful when
it looks like this:

 	python26.dll!PyObject_Malloc(unsigned int nbytes=32) ...
 	python26.dll!list_iter(_object * seq=0x03cf8720) ...
 	python26.dll!PyEval_EvalFrameEx(_frame * f=0x0403fef0,  ...
 	python26.dll!PyEval_EvalCodeEx(PyCodeObject * co=0x01621578, ... 	
 	python26.dll!function_call(_object * func=0x01674570, _object *  ...
 	python26.dll!instancemethod_call(_object * func=0x01674570, ... 
 	python26.dll!PyObject_Call(_object * func=0x03f83da0, _object ... 
 	python26.dll!slot_tp_call(_object * self=0x03cf8720, _object *  ...

Seeing immediately where I'm at in that thread's Python stack would be
hugely useful in tracking some of these kinds of problems down.

There is a file called gdbinit in the Python's Misc folder that does
exactly this for GDB:


Unfortunately, getting things going under GDB is a whole other project
in itself (unless of course, it can just read the PDB symbol files
that Visual Studio outputs...I'll have to check on that...)

Even just general strategies for getting your bearings in the debugger
when developing a Python extension would help me out :)

More information about the PyQt mailing list