[python-win32] Python script jumps back to 'main' in long running win32 event

Dave Angel davea at ieee.org
Fri Jun 25 15:24:52 CEST 2010


Robert Sudwarts wrote:
> Hi,
>
> I'm hoping that someone can help with this... I've seen some old posts which
> I think may refer to this same issue but I'm having difficulty understanding
> how to come up with a solution, and particularly where any
> "PumpWaitingMessages" should be located and/or/how/whether
>  pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) should be used.
>
> The code processes data for 25/30 messages received back from the com object
> but then seems to jump back to the 'if __name__ == '__main__' and passes
> that same parameter (originally passed from the command line) and runs all
> over again...
>
>   
Stab in the dark here:

Are you perhaps importing your original script as a module someplace?  
If you have recursive imports, you can actually see two instances of the 
same module, which can lead to the kind of behavior you're describing.

If your main script is called   main.py,  then search for any reference 
to main in another source file, in a line such as

import main
or
from main import fh

or some such.

DaveA



More information about the python-win32 mailing list