Why does SocketServer default allow_reuse_address = false?

Joshua J. Kugler joshua at eeinternet.com
Wed Mar 7 15:01:25 EST 2007


Greg Copeland wrote:
>> Is there some history to this of which I'm not aware?  Is there a good
>> reason for it to default to false?
<SNIP Greg's very informative reply>
> Long story short, it is not a bug.  It is a feature.  The proper
> default is that of the OS, which is to ensure SO_REUSEADDR is disabled
> unless you absoluetely understand what you're buying by enabling it.

Thanks for your reply.  Those are all point of which I had not been aware.

My problem (and the reason I set reuse to True) is this: if I have
connections active when I restart my service, upon restart, the socket will
fail to bind because there is still a connection in a WAIT state.  And
until that old connection goes away (30 seconds or so?) I cannot restart
the service.  So, the only option would be to sit there in a loop calling
serve_forever until it doesn't throw a "can't bind to socket" exception.

Or is there something I'm *really* missing about the way SocketServer is
supposed to work?  Am I supposed to notify my connection threads to shut
down and disconnect "properly?"  Which gets even more fun since they are
sitting there waiting for input on the connection and not in a position to
respond to other events...gets back to the fun of "killing" threads that
are blocking.

j

-- 
Joshua Kugler
Lead System Admin -- Senior Programmer
http://www.eeinternet.com
PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

-- 
Posted via a free Usenet account from http://www.teranews.com




More information about the Python-list mailing list