The same executable hosts most Python services, PythonService.exe . This special executable is aware of the special requirements for services that make Python.exe unsuitable for the task.
When PythonService.exe is asked to start a
service, it looks in the registry for the Python class that
implements the service. It then creates an instance of this class,
and delegates all service functionality to this instance. For
example, when the service is to start, a method named
SvcStart is called on the object. When the SCM
makes a control request, a method named
ServiceControlHandler is called. These Python
methods are expected to correctly report their status to the SCM, by
calling helper functions provided by
To make life as simple as possible for the Python programmer, a base
ServiceFramework is provided in the module
. The easiest way to write a service in
Python is to subclass this class, then concentrate on the service
functionality rather than on the interactions with the SCM.