[Python-Dev] sock.close() not closing?

Sjoerd Mullender sjoerd at acm.org
Wed May 7 12:49:50 CEST 2008


Why does sock.close() not actually close sock?

If I run the code

import socket
sock = socket.socket()
...
sock.close()

I would expect that a system call is done to actually close the socket 
and free the file descriptor.  But that does not happen.  Look at the 
code in socket.py.  It merely replaces the socket instance with a dummy 
instance so that all subsequent calls on the sock object fail, but it 
does nothing else!

-- 
Sjoerd Mullender


More information about the Python-Dev mailing list