[python-win32] Shell extension debugging

Gertjan Klein gklein at xs4all.nl
Sat Jul 4 12:06:02 CEST 2009


Mark Hammond wrote:

>I haven't caught up with the rest of the thread yet, but in my 
>experience, the shell keeps objects alive for as shorter time as 
>possible.  So you may find a completely new instance is requested for 
>each context menu request (or for each different item selected, or 
>something), so arranging to 'reload' your implementation module may well 
>work.  I've even used the 'Python.Server' object to reload via Exec() calls.

A quick test (printing id(self) in the shell extention's Initialize
method) seems to confirm that: it prints a different id each time. I
wouldn't know how to exploit this though. Ideally, during development,
I'd like the module to be reloaded for every invocation. The only way I
can see to do that is to use __del__ on the instance to delete the
module from sys.modules, but I've read that __del__ isn't all that
reliable, and I have no idea what it would do for the interaction with
pywin32. (I'm concerned about memory leaks for example.)

Oh, and how does one "reload via Exec() calls"?

Gertjan.




More information about the python-win32 mailing list