[python-win32] win32 service not receiving shutdown notification on reboot
timr at probo.com
Thu Dec 1 18:27:19 CET 2005
On Wed, 30 Nov 2005 17:41:32 +0100, Ralf Schmitt <ralf at brainbot.com>
>I use the attached program to start a win32 service.
>Stopping the service using the service manager works fine, but when I
>reboot the machine, the service just seems to be killed, without
>SvcStop/SvcShutdown being called (i.e. it never prints "DONE" on reboot).
>Tested on w2k using python2.3, and on XP using Python 2.4, both using
>Does anybody have an idea?
Umm, do you realize that your 'print "DONE"' statement is not part of
the SvcStop function, but rather the SvcDoRun function?
>#! /usr/bin/env python
>import win32serviceutil, win32service
> _svc_name_ = 'AA'
> _svc_display_name_ = 'AA'
> def SvcDoRun(self):
> # Can't use stdout for logging -- .flush will barf
> sys.stdout = open('c:/mylog.txt','a', 0)
> self.shouldStop = False
> while not self.shouldStop:
> print time.ctime(), "running"
> print "DONE"
> def SvcStop(self):
> self.shouldStop = True
> SvcShutdown = SvcStop
>if __name__ == '__main__':
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-win32