Re: [python-win32] Service stucks in Starting state

2018-04-12 Thread k3ops
Hi Tim,

> How did you start the service?? 
I run it with the following command line:
python MyService.py install
python MyService.py start

> How do you know this? How are you monitoring state?
When I go to Windows Services list its state is "Starting" instead of "Running" 
so I cannot do any actions on it (e.g Stop)

I managed to get the proper state "Running" by removing the following line from 
SvcDoRun function:
self.ReportServiceStatus(win32service.SERVICE_RUNNING)
since it's already called from parent function SvcRun from 
win32serviceutil.ServiceFramework that calls SvcDoRun.

But when typing "python MyService.py start", my Service gets stuck in "Running" 
state.
Here is the updated code, am I missing something to notify the service as 
stopped?


class MyClass(win32serviceutil.ServiceFramework):
# you can NET START/STOP the service by the following name
_svc_name_ = "My_CLASS"
# this text shows up as the service name in the Service
# Control Manager (SCM)
_svc_display_name_ = "MY_CLASS"
# this text shows up as the description in the SCM
_svc_description_ = "MY_DESC"

def __init__(self, args):
# create Windows Service
win32serviceutil.ServiceFramework.__init__(self, args)
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)  # create an 
event to listen for stop requests on

def SvcDoRun(self):
win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

def SvcStop(self):
# tell the SCM we're shutting down
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
# fire the stop event
win32event.SetEvent(self.hWaitStop)


___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


[python-win32] Service stuck in starting state

2018-04-12 Thread John Aherne
Have you looked in the event log to see if there are any messages to tell
you what might have happened.

Regards


-- 
*John Aherne*




*www.rocs.co.uk *
020 7223 7567
___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Service stuck in starting state

2018-04-12 Thread k3ops
I was using a queue message broker (pika) in the SvcDoRun function that was waiting for a new message (acting like an infinite loop). So actual stop event was not captured properly.Now I stop listening to the queue in the SvcStop function and everything works perfectly.Thanks for your help and time!Le 12 avr. 2018 4:04 PM, John Aherne  a écrit :Have you looked in the event log to see if there are any messages to tell you what might have happened.Regards-- John Ahernewww.rocs.co.uk020 7223 7567

___
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32