I did some more hunting around and now have the following: hscm = win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS) try: hs = win32serviceutil.SmartOpenService(hscm, cls._svc_name_, win32service.SERVICE_ALL_ACCESS) try: service_failure_actions = { 'ResetPeriod': 6000000, # Time in seconds after which to reset the failure count to zero. 'RebootMsg': '', 'lpCommand': '', 'Actions': [(win32service.SC_ACTION_RESTART, 60000), (win32service.SC_ACTION_RESTART, 60000)] } win32service.ChangeServiceConfig2(hs, win32service.SERVICE_CONFIG_FAILURE_ACTIONS, service_failure_actions) finally: win32service.CloseServiceHandle(hs) finally: win32service.CloseServiceHandle(hscm)
However, I'm getting the following error message: TypeError: SERVICE_FAILURE_ACTIONS must be a dictionary containing {'ResetPeriod':int,'RebootMsg':unicode,'lpCommand':unicode,'Actions':sequence of 2 tuples(int,int) Which I think is what I'm feeding it. Can someone please tell me what I'm doing wrong? A On Mon, Aug 8, 2011 at 7:06 PM, Andrew Hammond < andrew.george.hamm...@gmail.com> wrote: > I am trying to control the behavior of a service with regards to failure > handling as described here: > http://blogs.msdn.com/b/jcalev/archive/2008/01/10/some-tricks-with-service-restart-logic.aspx > > I have done some reading and have the following snippet of code that I > think is going in the right direction. However I don't know how to create > the action list. I suspect that it should be an array of unsigned long ints, > but... ??? > > > hscm = > win32service.OpenSCManager(None,None,win32service.SC_MANAGER_ALL_ACCESS) > > try: > hs = SmartOpenService(hscm, cls._svc_name_, > win32service.SERVICE_ALL_ACCESS) > try: > # What's the pythonic way to create these??? > action1 = Action() > action1.Type = win32service.SC_ACTION_RESTART > action1.Delay = 600 # 10 minutes? > > action2 = Action() > action2.Type = win32service.SC_ACTION_RESTART > action2.Delay = 600 > > action3 = Action() > action3.Type = win32service.SC_ACTION_RESTART > action3.Delay = 600 > > win32service.ChangeServiceConfig2( > hs, > win32service.SERVICE_CONFIG_FAILURE_ACTIONS, > [action1,action2,action3] # again, this isn't probably > right, but... ? > ) > finally: > win32service.CloseServiceHandle(hs) > finally: > win32service.CloseServiceHandle(hscm) > > Can anyone help please? > > Andrew >
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32