Managing a multiple threaded service
darwin at nowhere.com
Wed Jun 17 02:23:53 EDT 2009
New to Python ....
I've got 2 threads 1 is the SimpleHTTPRequestHandler, the other polls a site
for data. I want to run the program as a windows service.
My questions are:
Should both of them run as threads and then just have an infinite loop with
a sleep in the main thread in order to stop the main program from just
Or should I choose one of the threads to run as the main program and spawn
the other off? That was my original intention, but I am concerned that if I
use SimpleHTTPRequestHandler in the main thread, will it block any attempt
to terminate the service.
Just looking for pointers to the best practice approach. This is where I am
## Monitor changes on the server (separate thread)
monitor = monitor.monitor(fnLog=self.logStatus)
## Service interface
port = 8081
## To run the web server on a different thread...
## t = threading.Thread(target=server.serve_forever)
## t.setDaemon(True) # don't hang on exit
More information about the Python-list