On Tuesday, August 16, 2011 at 1:22:37 PM UTC+5:30, Tim Golden wrote: > On 16/08/2011 05:32, snorble wrote: > > Anyone know of a Python application running as a Windows service in > > production? I'm planning a network monitoring application that runs as > > a service and reports back to the central server. Sort of a heartbeat > > type agent to assist with "this server is down, go check on it" type > > situations. > > Don't know what it'll take to inspire you with confidence, but I have > several Python services running here without a hitch. > The longest have been running for about three years -- not without > a stop, since they have to be restarted for reasons external to the > service itself. > > There's no py2exe involved, just the pywin32 service wrappers. (The > apps in question are also set up to run standalone for testing etc.). > They're mostly around a helpdesk system: one app ingests email requests > to the helpdesk; another post-processes call changes, currently to > send out email alerts to interested parties; another triggers alarms > on calls for various purposes, etc. > > I don't claim they're the most sophisticated pieces of code on Earth, > but it doesn't sound like you're after anything spectacular either. > > TJG
hello everyone, I want to run a python file as a service in my windows7 , I am trying but not getting the proper sollution and i have written a script for this but not executing properly and i need to work this with postgresql import win32service import win32serviceutil import win32api import win32con import win32event import win32evtlogutil import os, sys, string, time ''' C:\>python aservice.py --username tarang --password 12345 --startup auto install ''' class aservice(win32serviceutil.ServiceFramework): _svc_name_ = "Trail Service" _svc_display_name_ = "Database Maintenance" _svc_description_ = "THis is what my crazy little service does - aka a DESCRIPTION! WHoa!" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): import servicemanager servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE,servicemanager.PYS_SERVICE_STARTED,(self._svc_name_, '')) self.timeout = 120000 #120 seconds / 2 minutes while 1: # Wait for service stop signal, if I timeout, loop again rc = win32event.WaitForSingleObject(self.hWaitStop, self.timeout) # Check to see if self.hWaitStop happened if rc == win32event.WAIT_OBJECT_0: # Stop signal encountered servicemanager.LogInfoMsg("TrailVersion - STOPPED!") break else: try: file_path = "D:\Tarang\Project\form1.py" execfile(file_path) inc_file_path2 = "D:\Tarang\Project\reter1.py" execfile(inc_file_path2) inc_file_path2 = "D:\Tarang\Project\exporting.py" execfile(inc_file_path2) except: pass def ctrlHandler(ctrlType): return True if __name__ == '__main__': win32api.SetConsoleCtrlHandler(ctrlHandler, True) win32serviceutil.HandleCommandLine(aservice) -- https://mail.python.org/mailman/listinfo/python-list