python1.5.2 + nt services + COM

Geoff Talvola gtalvola at
Fri Nov 9 20:36:51 CET 2001

At 12:44 PM 11/9/01 -0500, Steven Scott wrote:
>I'm not specifically using threads, although I am subclassing
>win32serviceutil.ServiceFramework as per the ntservice example that comes
>with win32all...I don't know if it does something with threads, but I'm led
>to believe that it's so.

That's probably the reason it doesn't work.  See Appendix D of Python 
Programming on Win32 for a good explanation of threading issues with 
COM.  Or if you don't have the book, the short version is, try calling:


at the beginning of the DoRun method (or if you'd prefer 
apartment-threading instead of free-threading, call 
pythoncom.CoInitialize() instead).  Also, you should call


at the end of the DoRun method.

The difference between apartment and free threading is covered pretty well 
in Python Programming on Win32.


- Geoff Talvola
   gtalvola at

More information about the Python-list mailing list