wierdness with pythonwin dialogs, threads & refcounts

Gordon McMillan gmcm at hypernet.com
Thu Jun 17 20:15:42 EDT 1999


Mark Hammond writes:

> There could be a number of leaks in Pythonwin, but I dont think
> dialogs do.
> 
> The ref count is likely to be 6, as the pywin.mfc.Dialog base class
> hooks a number of commands and messages.  Each of these hooks is a
> circular reference, as a bound method is saved away.  These
> references are deleted when a window recieves the WM_DESTROY
> message.
> 
> So in a nutshell, there is nothing obvious as to why the dialog is
> leaking. The very first step would be to ensure it does not leak
> without threads.
> 
> Otherwise, it may come down to me tracking this down, as there are
> some complicated interactions with MFC going on...

I played with this enough to find that he's onto something. Without
any threading, the dialog gets a WM_DESTROY and goes thru __del__.
When executed from a threading.Thread, it never goes thru OnDestroy.
I tried doing DoModal myself, then un-hooking the messages myself.
No luck. Perhaps because there's no parent window, and the trhead
does not have a Windows message queue?

> Dave Kirby wrote in message <3768b75e.5469224 at NNRP.UK.INSNET.NET>...
> >
> >I have found strange behaviour (strange to me at least) when creating
> >a pythonwin dialog on a separate thread created using the standard
> 
> 
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list

- Gordon




More information about the Python-list mailing list