Strange socket problem

Magnus Lycka lycka at
Wed Jun 15 17:46:50 CEST 2005

huy wrote:
> Hi,
> I'm using cherrypy to provide a user interface for users to start a 
> linux server program eg. os.system("nohup &"). The problem 
> is that if I stop cherrypy server and restart, I get the "Address 
> Already In Use" problem until I stop Can someone shed some 
> light on why this happens ? Why would the socket be held up in the other 
> process ?

As I understand it, if a socket is closed by the server, the OS
will typically hold on to the socket for a while, in case the
client wants some packages resent etc. This might be a part of
your problem.

Andrew Dalke explained it much better to me when I ran into this
some time ago. Quoted below:

> Magnus Lyckå wrote:
>> Why doesn't my socket
>> get released by the OS when I exit via my handle_error?
> Hi Magnus,
>   I wrote about this at
> The reason for it is described at
> You can set the class variable "allow_reuse_address = True" in
> your derived ExitableSocketServer to get the behaviour you
> expect, at the expense of some problems mentioned in the
> above URL.
>     Andrew
>     dalke at

More information about the Python-list mailing list