making a Windows NT service out of a python program

Bill Tutt billtut at microsoft.com
Thu Jul 15 10:05:52 EDT 1999


> From: Haimo G. Zobernig [mailto:Haimo.Zobernig at cern.ch]
> 
> Am I doing something wrong, or does that really not work?
> I'd like to be sure that the examples work before I adapt 
> them to my own
> programs.
> 

There are at least one thing wrong with the code, and another thing wrong
with Python 1.5.2 (race condition in deleting thread states).
If you ran the service in debug mode, you might see a message that says
something about trying to delete an invalid threadstate, and python
execution.
You can run the service in debug mode via:
	python pipeTestService.py debug

The sample code for testing large messages is broken.
The service only sees the first 256 bytes of the message.
(Not sure why yet...)
The other problem, is that the call to send the large message is broken as
well.

Here's the bogus line in question:
	data = CallPipe(CallNamedPipe, ("\\\\%s\\pipe\\PyPipeTest" % server,
msg, 512, NMPWAIT_WAIT_FOREVER))

This should be something like:
	data = CallPipe(CallNamedPipe, ("\\\\%s\\pipe\\PyPipeTest" % server,
msg, len(msg)+256, NMPWAIT_WAIT_FOREVER))

If the service had actually read all 4k of the incoming data, CallNamedPipe
would have thrown an exception.

So there's nothing wrong with the service code, just with the sample pipe
handling code. :)

Bill




More information about the Python-list mailing list