[python-win32] creating a long-running Python COM server
Mark Hammond
mhammond at skippinet.com.au
Sun Sep 17 11:39:41 CEST 2006
> I will write this up as a recipe in the Python Cookbook; any comments
> on my code (attached)?
The 'busy loop' looks ugly to my eyes. It can be solved by importing
win32gui, then changing the Quit method to:
def Quit(self):
win32gui.PostQuitMessage(0)
and the entire busy loop gets replaced with:
pythoncom.PumpMessages()
That obviously breaks the 'loops' variable though.
I also changed the if __name__ block to:
if __name__ == '__main__':
register()
main()
unregister()
That way, running it as a script "does the right thing" in a single step.
Cheers,
Mark
More information about the Python-win32
mailing list