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

Robert Brewer fumanchu at aminus.org
Wed May 7 18:07:08 CEST 2008


Sjoerd Mullender wrote:

On 2008-05-07 13:37, Amaury Forgeot d'Arc wrote: > 2008/5/7 Sjoerd Mullender <sjoerd at acm.org>: >> I would expect that a system call is done to actually close the >> socket and free the file descriptor. But that does not happen. > > It does close the socket: > > In socket.py, when self.sock is replaced, its del method will be > called.

I have to question the design of this. When I close() an object I expect it to be closed there and then and not at some indeterminate later time (well, it is determinate when you're fully aware of all references, but often you aren't--trust me, I understand reference counting).

Even if you're fully aware of all references, it's indeterminate in multithreaded apps. I've just taken to doing:

self.socket._sock.close()
self.socket.close()

...in order to send the FIN I wanted ASAP.

Robert Brewer fumanchu at aminus.org



More information about the Python-Dev mailing list