473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

problem with a python service

Hello everybody!

I'm very bad in English but I'm going to try to explain my problem.

I have a python program and this program is a service.

chronologically:
1. I install my program like service -> it's ok
2. I start the service -> it's ok
3. I stop the service -> it's ok
4. I remove the service -> it's ok
5. I install a new version of my program like service -> it's ok
6. i try to start my new service but it don't start.

If I remove the new service and I install the old service I don't arrive
to start my old service.

If I launch my program like a process, the program start.

Is it possible that the service is badly remove? How to make to check it?

I install my service with the command: "myService.py --startup auto
--interactive install"

I remove my service with the command: "myService.py remove"

I start my service with the command: "net start pampa" (pampa is the
service name)

I stop my service with the command: "net stop pampa"

Here the code of my service:

import win32serviceutil, win32service
import pywintypes, win32con, winerror

from win32event import *
from win32file import *
from win32pipe import *
from win32api import *
from ntsecuritycon import *

import log
import PampaClient
import time

class PampaService (win32serviceutil.ServiceFramework):

_svc_name_ = 'Pampa'
_svc_display_name_ = 'Pampa Client pour WinNT'

def __init__ (self,args):
win32serviceutil.ServiceFramework.__init__(self,ar gs)
self.hWaitStop = CreateEvent(None, 0, 0, None)

def SvcStop(self):
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING)
SetEvent(self.hWaitStop)

def SvcDoRun(self):
import servicemanager
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ' Youpi ?')
)
programmePrincipal = PampaClient.PampaClient()
try :
programmePrincipal.main()
except :
shutDownThread = programmePrincipal.getShutDownThread()
shutDownThread.setService(self)
while 1:
rc = WaitForMultipleObjects((self.hWaitStop,), 0, 1000)
if rc==WAIT_OBJECT_0:
break

self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING,
5000)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,
(self._svc_name_, ' Arret en cours')
)

shutDownThread.shutDown()
finir
while shutDownThread.isAlive():
time.sleep(2)
self.ReportServiceStatus(win32service.SERVICE_STOP _PENDING, 5000)
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STOPPED,
(self._svc_name_, ' Youpiiiii c\'est fini')
)
if __name__=='__main__':
win32serviceutil.HandleCommandLine(PampaService)
thank you in advance for your reponses,

Christophe

Jul 18 '05 #1
0 1375

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Rene Olsthoorn | last post by:
Dear readers, py2exe has a problem including libxml2. Not at building time, but at runtime. The libxml2.dll cannot be loaded... Is there anyone that NOT has the problem? (and can you drop me...
0
by: David Mitchell | last post by:
Hello group, I'm trying to create a TCP server using Python, and I want it to run under Windows as a service. Now, I'm fine with building the TCP server using Python - done it lots of times,...
3
by: David Fraser | last post by:
Hi We are trying to debug a problem with services created using py2exe. It seems that these problems have arisen after services were installed and removed a few times. OK, first the actual...
12
by: Richard Hanson | last post by:
Over the last few days, I reinstalled Win2kSP2 to a spare harddrive I had just swapped into my Fujitsu LifeBook P1120 (long story <wink>). Subsequently, I DL'ed the newest Python alpha (2.4a2), and...
1
by: Laszlo Zsolt Nagy | last post by:
Hi All! I have a running service (a small web server) implemented in python, running as a win32 service. I wrote another program that is very similar to the web server but I cannot start the...
6
by: Laszlo Zsolt Nagy | last post by:
Sorry, I realized that the import zlib was not executed from my (working) service. So here is the question: why can't I use zlib from a win32 service? Is there any way to make it working? ...
2
by: pruebauno | last post by:
I am currently working on a tricky problem at work. I googled around a bit, but "time intervals" did not come up with anything useful. Although I have some rough idea of how I could solve it, I...
3
by: zxo102 | last post by:
Hi there, I have a python application (many python scripts) and I start the application like this python myServer.py start in window. It is running in dos window. Now I would like to put it...
2
by: Gabriel Rossetti | last post by:
Hello everyone, I'm trying to use python's freeze utility but I'm running into problems. I called it like this : python /usr/share/doc/python2.5/examples/Tools/freeze/freeze.py...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.