Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87725 > unrolled thread
| Started by | jyothi.nadu@gmail.com |
|---|---|
| First post | 2015-03-19 00:00 -0700 |
| Last post | 2015-03-19 19:20 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Windows service in production? jyothi.nadu@gmail.com - 2015-03-19 00:00 -0700
Re: Windows service in production? Michiel Overtoom <motoom@xs4all.nl> - 2015-03-19 19:20 +0100
| From | jyothi.nadu@gmail.com |
|---|---|
| Date | 2015-03-19 00:00 -0700 |
| Subject | Re: Windows service in production? |
| Message-ID | <6e1d77bd-8289-478f-a44a-35b2be3dac0d@googlegroups.com> |
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)
[toc] | [next] | [standalone]
| From | Michiel Overtoom <motoom@xs4all.nl> |
|---|---|
| Date | 2015-03-19 19:20 +0100 |
| Message-ID | <mailman.26.1426789317.10327.python-list@python.org> |
| In reply to | #87725 |
On Mar 19, 2015, at 08:00, jyothi.nadu@gmail.com wrote:
> file_path = "D:\Tarang\Project\form1.py"
Use either slashes (/), raw strings, or double backslashes:
file_path = "D:/Tarang/Project/form1.py"
file_path = r"D:\Tarang\Project\form1.py"
file_path = "D:\\Tarang\\Project\\form1.py"
--
"You can't actually make computers run faster, you can only make them do less." - RiderOfGiraffes
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web