windows service problem

Discussion in 'Python' started by Austin, Jun 24, 2005.

  1. Austin

    Austin Guest

    class HelloService(win32serviceutil.ServiceFramework):
    _svc_name_ = "HelloService"
    _svc_display_name_ = "Hello Service"
    def __init__(self,args):
    win32serviceutil.ServiceFramework.__init__(self,args)
    self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
    self.check = 1

    def SvcStop(self):
    self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
    win32event.SetEvent(self.hWaitStop)
    self.check = 0

    def SvcDoRun(self):
    win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)
    while True:
    CheckPoint('SvcDoRun')
    if self.check == 0:
    break

    if __name__ == '__main__':
    win32serviceutil.HandleCommandLine(HelloService)

    -----------------------------------------------------------------------

    I modified the demo code from Python Programming on Win32.
    CheckPoint is a class to open a file and write some words.
    But the problem is that no matter how I re-start the service and the
    CheckPoint() doesn't work.
    Anything wrong?
    Austin, Jun 24, 2005
    #1
    1. Advertising

  2. On 6/24/05, Austin <> wrote:
    > def __init__(self,args):
    > win32serviceutil.ServiceFramework.__init__(self,args)
    > self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
    > self.check = 1


    Change last two lines to

    self.check = 1
    self.hWaitStop = win32event.CreateEvent(None, 0, 1, None)

    (SvcDoRun is waiting for hWaitStop event, but you never signal it.)

    - kv
    Konstantin Veretennicov, Jun 25, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?c2h5YW0=?=
    Replies:
    2
    Views:
    690
    =?Utf-8?B?c2h5YW0=?=
    May 22, 2006
  2. prowyh
    Replies:
    0
    Views:
    306
    prowyh
    Nov 16, 2007
  3. Billy Zhang
    Replies:
    7
    Views:
    1,137
    Steven Cheng [MSFT]
    Jul 31, 2008
  4. tshad

    Windows Service Service name

    tshad, Oct 14, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    400
    Mr. Arnold
    Oct 15, 2009
  5. Replies:
    1
    Views:
    224
    Joe Kaplan \(MVP - ADSI\)
    Jun 14, 2006
Loading...

Share This Page