[python-win32] Issues with service startup

Vernon D. Cole vernondcole at gmail.com
Tue Oct 8 09:09:31 CEST 2013


This answer is a bandage, not a cure, but perhaps it will be enough in your
case...

The first moments of operation when a system (especially a server) is
booting up are replete with programs demanding resources which may not be
available yet. I found that simply adding a Python time.sleep() call near
the beginning of my program made the difference in reliability.

If you feel that package initialization may be part of the problem,
remember that in Python  "import" is an executed statement. We often treat
it as if it were a compiler declaration, but it is not.  So if you...
>>>import time
>>>print('Waiting for system to settle down...')
>>>time.sleep(30)
>>>import big_package
then "big_package" will not be imported until after things settle down.

I hope you find out what is *really* causing your problem, but until then,
try the quick and dirty work-around.
--
Vernon

On Mon, Oct 7, 2013 at 3:08 PM, Stan <s at vtwireless.com> wrote:

> Has anyone dealt with Python based Windows Services not starting properly
> at system boot?  They start immediately after boot, but not at boot.
>  Attempting to use various dependencies to make it start up later in the
> process hasn't seemed to help.
>
> I have to separate codebases that exhibit this issue, their commonality is
> they both connect to a PostgreSQL database on the machine, and use
> multiprocessing and threading.
>
> I don't have the issue narrowed down to a test case that exhibits the
> issue, but it occurs on some systems every single time, and on others only
> intermittently.
>
> For one of the two, delaying at service startup (sleep...) before
> importing wmi and pythoncom libraries seemed to cause it to stop failing at
> startup.  The other does not seem to use wmi/pythoncom directly.
>
> Event Type: Error
> Event Source: Service Control Manager
> Event Category: None
> Event ID: 7009
> Date: 10/5/2013
> Time: 2:35:49 PM
> User: N/A
> Computer: WINDOWSTEST1
> Description:
> Timeout (30000 milliseconds) waiting for the MyTestApp1 service to connect.
>
> For more information, see Help and Support Center at
> http://go.microsoft.com/fwlink/events.asp.
>
> Event Type: Error
> Event Source: Service Control Manager
> Event Category: None
> Event ID: 7000
> Date: 10/5/2013
> Time: 2:35:49 PM
> User: N/A
> Computer: WINDOWSTEST1
> Description:
> The MyTestApp1 service failed to start due to the following error:
> The service did not respond to the start or control request in a timely
> fashion.
>
> For more information, see Help and Support Center at
> http://go.microsoft.com/fwlink/events.asp.
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20131008/b9c18761/attachment.html>


More information about the python-win32 mailing list