run python script continuously windows

Solutions on MaxInterview for run python script continuously windows by the best coders in the world

showing results for - "run python script continuously windows"
Miranda
09 Apr 2018
1# Creating windows service to ensure continuous run
2import win32serviceutil
3import win32service
4import win32event
5import servicemanager
6import socket
7
8
9class AppServerSvc (win32serviceutil.ServiceFramework):
10    _svc_name_ = "TestService"
11    _svc_display_name_ = "Test Service"
12
13    def __init__(self,args):
14        win32serviceutil.ServiceFramework.__init__(self,args)
15        self.hWaitStop = win32event.CreateEvent(None,0,0,None)
16        socket.setdefaulttimeout(60)
17
18    def SvcStop(self):
19        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
20        win32event.SetEvent(self.hWaitStop)
21
22    def SvcDoRun(self):
23        servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,
24                              servicemanager.PYS_SERVICE_STARTED,
25                              (self._svc_name_,''))
26        self.main()
27
28    def main(self):
29        pass
30
31if __name__ == '__main__':
32    win32serviceutil.HandleCommandLine(AppServerSvc)
similar questions
queries leading to this page
run python script continuously windows