It's number 4.  You need to read up on windows services.
The service monitor will not forcibly kill your service.  The service monitor starts your application and uses a callback to notify your service of certain events.  It is the responsibility or the service to respond to these events accordingly and to communicate with the service control manager.

By doing "while true: pass"  your service is not bothering to check if the service manager has asked it to stop.  The typical scenario is to set and event or flag when you get the callback telling you to stop and then checking for this condition in your main loop.

Maybe this will help

On Feb 7, 2008 8:22 AM, Marc Planard <> wrote:

First of all, i must confess i'm barely win32 literate and a novice
python coder.

I had to deal with windows services and choose to do it with py2exe.

I've taken the first working example around:
(in French, but the code works)

I've played with it and now I have a fully functional windows service,

But when I try to stress test my service, I notice something I didn't
expect: the services system doesn't seem to deal nicely with not
responding services. I.E. if I put a "while true: pass" in my main
loop, the system doesn't notice that my service doesn't answer anymore,
it doesn't even manage to kill it nicely.

You can reproduce this behavior by adding the "while loop of death" in
DoBatch() in the above example.

I'm puzzled with that and I see only 4 options:
1/ the code I've taken is broken somehow, and don't allow the system
to be informed of the malfunction of the rest of the code
2/ py2exe is broken^W^W not finished and doesn't allow the system to
monitor py2exe services nicely
3/ Windows services are poorly implemented and doesn't allow to detect
when a service doesn't respond to events anymore.
4/ I've missed something important.

Of course [4] is the more probable answer, yet I wish someone skilled
explains me what's going on here.

Thank you for your attention.
Marc Planard

This email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
Py2exe-users mailing list