Re: What happens in a Python service in case of exception thrown?

Mark Hammond <[email protected]> Thu, 3 Mar 2022 16:37:25 +1100
Newsgroups gmane.comp.python.windows
Message-ID <[email protected]>
On 3/03/2022 4:21 pm, Siyuan Ren wrote:
> I'm trying to subclass win32serviceutil.ServiceFramework in order to 
> create a Windows service in Python. I vaguely understand how each stage 
> of service works, but I wonder, what happens if any of the python code 
> throws an exception? Will the service stop, or put in an abnormal state 
> without recourse?

In general it will log a message to the eventlog and stop. Up until 
https://github.com/mhammond/pywin32/issues/1563 & 
https://github.com/mhammond/pywin32/pull/1566, it ended up reporting a 
normal `SERVICE_STOPPED` with an exit code of zero, but now it reports a 
non-zero code so you can configure it to auto-restart on exceptions.

HTH,

Mark
_______________________________________________
python-win32 mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-win32