BaseHTTPServer

Chris Liechti cliechti at gmx.net
Sat Apr 6 13:35:24 EST 2002


"FrancescO" <francesco.contini at tiscalinet.it> wrote in
news:a8ljkn$6ht$1 at lacerta.tiscalinet.it: 
> but... if i try to stop and restart the server i have an exception:
> port already in use
...
> after a minutes, or more,  the port is free... and i can restart the
> program, but, obviously,
...
> I don't run a particular code to stop.. (kill -9 ;P ) and i like to

so don't use SIGKILL! when you kill a proces it is terminated by the OS. it 
keeps sockets closed for some time so that hanging connections time out and 
don't give problems with a newly started server on the same port.

if you stop the program with an other signal like SIGTERM python has the 
chance to clean up and the socket is freed, so that you can immediately use 
the port again.

> use the same way used
> by the /etc/init.d/... scripts to start and stop.

i have a daemon wrapper script and init.d script for a Debian/Linux system 
if you're interested.

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list