[python-win32] Windows service problem

Mark Hammond mhammond at skippinet.com.au
Tue Jun 12 15:42:52 CEST 2007


I've never seen this as described, but it sounds familiar - most services I
work with tend to be either LocalSystem or with their own "dedicated"
account, which both avoid this issue.  When you log out, applications
running under that account may be sent a "control handler" with
CTRL_LOGOFF_EVENT event and may have certain system calls interrupted.  You
may like to look into win32api.SetConsoleCtrlHandler() and see if explicitly
handling/ignoring that event helps (looking at the MSDN docs for this
function will also be vital)
 
Cheers,
 
Mark

-----Original Message-----
From: python-win32-bounces at python.org
[mailto:python-win32-bounces at python.org]On Behalf Of Dalton, Tom
Sent: Tuesday, 12 June 2007 10:28 PM
To: python-win32 at python.org
Subject: [python-win32] Windows service problem



Hi,

I'm using pywin32 on WinXP embedded to run a server service (using
Win32serviceutil.py). The service is installed correctly and set up to run
automatically on startup, which it does. The machine boots to the logon
screen and the service can be verified to be running correctly.

If I now log onto the machine as administrator, the service is still
running. When I log off however, I return to the windows logon screen, but
the service seems to have stopped. Logging back in as administrator, the
Windows services screen says the service has stopped. When I check the
system log for applications, the following is logged:

The instance's SvcRun() method failed
  File "C:\python24\lib\site-packages\win32\lib\win32serviceutil.py" line
742, in self.SvcDoRun()
  File "C:\myservice\myservice.py" line 123 in SvcDoRun time.sleep(5)
exceptions.IOError: (4, "Interrupted function call")

What does this mean? Why does logging out of the Admin account affect a
background service? Is this a known issue? I've copied the example and
modified very little. My service is effectively an infinite loop that
periodically checks if the 'real' server process (another python program)
has died, and if so restarts it. Is this some weird issue with using sleep
within the service's main method? If so, how can I get round this problem?

I'm using pywin 2.0.4 and python 2.4.3

Thanks for any help anyone can give :-)

Tom 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4520 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-win32/attachments/20070612/4dab9caa/attachment.bin 


More information about the Python-win32 mailing list