Hi.

This post is similar to one sent by Tom Dalton 12 June 2007. 
Unfortunately, appropriate solution of his problem was not published yet.

I'm trying to create a simple windows service. I found code of simple 
service on the Internet. Service works well as long as I'm logged in. 
But as soon as I log out the service is interrupted and windows event 
log contains the following message:

The instance's SvcRun() method failed
File "C:\Python25\Lib\site-packages\win32\lib\win32serviceutil.py", line 
785, in SvcRun
  self.SvcDoRun()
File "C:\altworx_repository\wwwroot\cgi-bin\pokus\aservice.py", line 20, 
in SvcDoRun
  time.sleep(10)
<type 'exceptions.IOError'>: (4, 'Interrupted function call')

Service is running on Windows XP Prof with Python 2.5. Code of the 
service is bellow. Has anyone any idea what's wrong? Thank you for any 
little help.

import win32service
import win32serviceutil
import time
import win32api
import win32con

class aservice(win32serviceutil.ServiceFramework):
 _svc_name_ = "aservice"
 _svc_display_name_ = "aservice - It Does nothing"

 def __init__(self,args):
    win32serviceutil.ServiceFramework.__init__(self,args)
    self.isAlive = True

 def SvcDoRun(self):
    import servicemanager

    while self.isAlive:
       servicemanager.LogInfoMsg("aservice - is alive and well")
       time.sleep(10)
    servicemanager.LogInfoMsg("aservice - Stopped")

 def SvcStop(self):
    import servicemanager

    servicemanager.LogInfoMsg("aservice - Recieved stop signal")
    self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
    self.isAlive = False

def ctrlHandler(ctrlType):
 return True

if __name__ == '__main__':
 win32api.SetConsoleCtrlHandler(ctrlHandler, True)
 win32serviceutil.HandleCommandLine(aservice)


This code is slightly modified. The original code is on 
http://essiene.blogspot.com/2005/04/python-windows-services.html.

Z.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to