making a Windows NT service out of a python program
Mark Hammond
MHammond at skippinet.com.au
Tue Jul 13 10:37:28 EDT 1999
More information about the Python-list mailing list
Tue Jul 13 10:37:28 EDT 1999
- Previous message (by thread): making a Windows NT service out of a python program
- Next message (by thread): making a Windows NT service out of a python program
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Christian Tismer wrote in message <378B2AA8.58477120 at appliedbiometrics.com>... >This is all great stuff if you have understood it already. >For me, it is still unclear what makes up a service, and >what I need at the minimum to turn a Python program into >an NT service. > >I need nothing more than to run Medusa as a service. Did >anybody do this before? Do I need special calls at all? Here are services explained in as few lines as possible: NT designed services to be capable of responding asynchronously to requests. While a service is working, NT can send a stop/pause etc request. The service can take pretty much as long as it likes to complete the request, but it must be very quick about telling NT it is responding, and the state change is pending (and continue to tell it until the transition is complete). At the raw API level, a service starts up by passing a callback function back to NT. Whenever NT needs to control the service, it calls this function. Thus, services are almost always threaded - one thread doing the work of the service, and another responding to service control messages. Could be single threaded, but the single thread must be fully asynchronous for this to work. So, the short answer is that to _really_ work as a service properly, a program must be written as a service (then the next thing people want are event log messages and performance monitor data!). Short of that, it would actually be trivial to write a service that could run any arbitary Python script. You would not have the same level of control (eg, how would you shut down the script - you cant target exceptions at threads in Python). It would actually be even simpler to write a "srvany" in Python - it could use the win32process functions to execute any arbitary program, and take whatever action was necessary if it terminated prematurely. Services get a decent going over in our book :-) Mark.
- Previous message (by thread): making a Windows NT service out of a python program
- Next message (by thread): making a Windows NT service out of a python program
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list