Windows service and pyc files

Laszlo Nagy gandalf at designaproduct.biz
Wed Apr 4 11:48:48 EDT 2007


 Hello,

I have a win32 service written in Python that starts a plain 
application, written in Python.

The win32 service tries to launch the application in a while loop and 
logs the return value of the os.system call. That's all.

The application is a simple Python program that connects to an https 
xml/rpc server, and works with the data retrieved from that server. It 
is written as an application because it must be able to download updates 
for itself. Here is how it works:

a.) connect to server
b.) compare current version with the latest
c.) if there is a difference, then download all sources from the server, 
delete all pyc files and exit; otherwise start processing

I could not write a self-restarting server, and I did not want to 
write/install two services for one problem. The win32 service is very 
small and primitive so probably I will not need to update it. I think 
the basic idea is good, but...

When there is a client update available, my application updates itself 
cleanly and exists. Then the service tries to restart the application, 
but it cannot. os.system returns with OS error code -1. The pyc files 
are NOT generated for the application. However, if I start the 
application from the command line, then pyc files are created, and then 
the service will also start the application immediatelly. The win32 
service is running as "Localsystem" so it is sure that it has write 
permission on all files.

I cannot log out the error from the application since it is not started. 
The only error message I have is OSError -1, but it tells me nothing 
about the nature of the error.

Thanks,

   Laszlo




More information about the Python-list mailing list