[PyQt] Any way to run code before each QThread?

John Ehresman jpe at wingware.com
Sun Jul 15 17:06:06 BST 2018

On 7/15/18 11:46 AM, Phil Thompson wrote:
> Should I implement QThread.settrace()?
> If so can somebody clarify what thread the call to sys.settrace() should be made in? The new thread or the thread from which the new thread is created?

It would be better to use the callback function that is passed to 
threading.settrace than to add QThread.settrace.  It's available as 
threading._trace_hook  The sys.settrace function should be called on the 
new thread before any Python code on that thread.

The ugly hack that Wing's debugger uses is to wrap to run method of a 
QThread instance that sets up the debugger for the thread and then calls 
the original run method.



More information about the PyQt mailing list