[python-win32] Service does not start at windows boot but at user's login

le dahut le.dahut at laposte.net
Mon Jun 9 16:40:18 CEST 2008


I suppose that the user's program throws an exception if the service 
isn't started yet.

I propose this :

while True:
  try:
	do_what_fails_if_service_isn_t_started
	break
  except:
	time.sleep(0.5)

I've this problem when using wipfw and twisted's reactor.


stephane.poirot wrote :
> Good morning,
> 
> I'm currently building an application which involves two different 
> processes : one is a service and the other one is a simple client.
> My client starts at user's login and the service should start at windows 
> boot. I say 'should' because it seems that the service
> actually starts at user's login too : I put logs in the event log and I 
> noticed that the service starts almost 7 to 10 seconds after
> the client, which is not what is expected. Service's properties are : 
> run automatically on System account, no dependencies.
> The code of my service is based on the one found in the book : Oreilly, 
> Python Programming on Win32, at chapter 18.6 :
> Sample Service Written in Python.
> 
> 
> Furthermore, my two processes communicate through a named pipe, and the 
> problem aforementioned involves that the communication
> is not possible : indeed, the service, who should start before the 
> client, creates the pipe and waits for a client connection. Client has just
> to open  the pipe to connect. But obviously if the client starts before 
> the service, an error occurs because no pipe is created so far.
> 
> I did a lot of searches to solve this problem, but haven't found any 
> issue yet.
> I first thought that  the problem came from pythonservice.exe, which 
> hosts my service : it may take longer time
> to load than common other windows services. That's why I converted my 
> service into a .exe thanks to py2exe. Then the path in service's
> properties has changed to this executable. But the problem remains : 
> service still starts after client.
> However, the problem only occurs at first user's login after machine's 
> boot : if he disconnects and somebody connects after, without reboot, 
> the service is
> still running, which is normal.
> 
> That's why I would ask if anyone  has an idea for solving this problem.
> Thank you in advance for your answers.
> 
> Stéphane POIROT


More information about the python-win32 mailing list