[python-win32] Service on Win2k and Timer

kj7ny kj7ny at yahoo.com
Mon Jul 21 11:58:00 EDT 2003


I have read several posts here that appear to address my issue but they 
all went way over my head!  Hopefully I can get an answer here that is 
'dumbed down' enough for me to understand it :)

I believe I am trying to do pretty much the same thing as Sean in the 
post: "Executing a remote process via WMI in Win32." ... but not nearly 
at the same advanced level.  (I'm not sure I need to go the WMI route.)

I am writing Python code to perform remote updates of software across a 
WAN (all Win2K machines).

However, at this point, all I have to do is unzip one or more files and 
tweak some config settings.  (It may be enhanced to do more in the 
future but that will depend upon the success of this effort.)

I control the entire process with a MySQL database.

I have no problems with any access permissions, with any MySQL access, 
with the unzip or tweak processes.

I started the utility by using the py2exe Windows Service sample code.

I have a service that runs well (as far as I can tell).

I have code that does the processing once it is fired off (it isn't 
completely finished but I anticipate no major surprises).

The issue is my lack of understanding of how to correctly create the 
timer event within the service.

I created a while(1) loop with a time.sleep(nsecs) which works, but I 
can't stop the service without first killing the while(1) loop and I am 
not convinced that I am not using up too much of the processor and 
making this thing a hog that I won't be able to use.

During development, I am running a time.sleep(5) to time.sleep(60) just 
so I can keep testing.  In real life, it will probably be checking in 
somewhere from once an hour to once a day.

How should I create a timer within the service so that this thing is as 
unintrusive as possible when it isn't actually performing an update and 
so that it runs nicely as a service and can be started and stopped 
gracefully?

Thanks,





More information about the Python-win32 mailing list