On 4/11/2012 1:20 PM, Rob McGillivray wrote:
Hi All,
For the life of me I cannot figure out why SvcShutdown() is not being called when
the OS shuts down. All the other SCM notifications (pause/continue/stop) work just
fine. I have searched high & low for solutions, but nothing. What appears to be
a slam-dunk for others completely evades me. I must be missing something, so I
bought a copy of Programming on Win32, but the Services section hasn't shed any
more light on the issue, so I humbly ask for enlightenment. :-) What the heck am I
missing??
Your help would be much appreciated!
Thanks in advance,
Rob
I'm guessing here, but...
def SvcShutdown(self):
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
self.logEvent('**SvcShutdown event**')
It is possible that by the time you get here the eventlog service has
also stopped. Have you tried to verify the call any other way (eg,
writing a line to a file?
# Shutdown code here...
win32event.SetEvent(self.evStop)
Your shutdown code probably shouldn't be there - it should be in the
main SvcDoRun function - how much of a problem this is probably depends
on how much work it does.
Also, your use of events seems a little fragile - would it be possible
for you to use manual reset events, so that your notificationFromSCM()
function doesn't reset the event?
Even better would be to remove it completely - your sleep() function
could just a WaitForMultipleObjects with a timeout of sec*1000.
So if you still have problems, it might be best to demonstrate it with
one of the sample pywin32 services so (a) we can reproduce it and (b) it
eliminates some of the complexity in your real service.
HTH,
Mark
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32