How to free a port that has been used by a python server?

Alex cut_me_out at hotmail.com
Sat Jun 3 01:15:30 EDT 2000


Hi.  I have some code like this:

######################################################################
class Server (SocketServer.ThreadingMixIn,
	      BaseHTTPServer.HTTPServer):
    pass
    
if __name__ == '__main__':

    port = 1729 # Called from interactive session, debug mode.

    proxy =  Server (('127.0.0.1', port), Handler)
    proxy.serve_forever ()
######################################################################
    
The problem is, when I run this more than once in interactive mode, I
get the error:

socket.error: (98, 'Address already in use')

Is there some way to free up port 1729 when proxy gets destroyed?  

I'm running RedHat Linux, but I have also seen this problem with
Solaris. 

Alex.



More information about the Python-list mailing list