[python-win32] HTTP Server as a Windows Service
Mark Hammond
mhammond at skippinet.com.au
Mon Feb 25 14:08:30 CET 2008
I'm afraid I haven't followed this closely, but:
> The real problem here is that the OP hasn't notified the service
> control manager that it has stopped, once SvcDoRun completes. He needs
> a call to self.ReportServiceStatus(win32service.SERVICE_STOPPED)
> outside the while loop in SvcDoRun. Otherwise the status never gets
> set to "Stop", and remains at "Stopping" as he is seeing.
The above *should* be incorrect (and actually is, best I can tell). The
tail of SvcRun, which is called by the C++ code, reads:
# Once SvcDoRun terminates, the service has stopped.
# We tell the SCM the service is still stopping - the C framework
# will automatically tell the SCM it has stopped when this returns.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
and a quick look at the C++ code shows this should indeed be true. Looking
at pipeTestService.py, it never explicitly sets the state to SERVICE_STOPPED
either, and it has always been my intent that the final stopped state be
automatic as the handler terminates.
So even if the OP overrides SvcRun directly, it should be impossible to
avoid a stopped state being notified. Unless the fact I'm too lazy to big
into the thread plays a part in a misunderstanding... :)
Cheers,
Mark
More information about the python-win32
mailing list