O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Anatomy of a Python Service

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 PythonService.exe.

To make life as simple as possible for the Python programmer, a base class ServiceFramework is provided in the module win32serviceutil . 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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required