SimpleHTTPServer problems when tying up main thread

t_e_sanders at my-deja.com t_e_sanders at my-deja.com
Wed Mar 29 15:39:29 EST 2000


Howdy. I'm experiencing problems when I try to use
SimpleHTTPServer while tying up the main thread;
specifically, I'm calling code roughly as follows:

> # Start the server up:
> server=SimpleHTTPServer.HTTPServer((address, >
port), webserver)
> thread.start_new_thread(server.serve_forever,
())
>
> # Do something forever:
> while 1:
>         time.sleep(1.0)
>         unrelated_stuff()

It seems that if I let the main thread run out
such that I get the ">>>" prompt, the server acts
normally; however, when I prevent the main thread
from completing the script, the page is never
served. BasicHTTPServer.handle_request() seems to
complete, but it the page never gets out;
SimmpleHTTPServer's log_request never gets
called.

I must be missing something thread-related, but I
can't seem to track it down; can anyone offer any
advice?

Thanks much,
Thomas Sanders
t.e.sanders at usa.net


Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list