A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-June/065991.html below:

[Python-Dev] socket._socketobject.close() doesn't really close sockets

[Python-Dev] socket._socketobject.close() doesn't really close sockets [Python-Dev] socket._socketobject.close() doesn't really close socketsBruce Christensen t-bruch at microsoft.com
Tue Jun 13 01:47:02 CEST 2006
In implementing the IronPython _socket module, I've discovered some
puzzling behavior in the standard Python socket wrapper module:
socket._socketobject.close() doesn't actually close sockets; rather, it
just sets _sock to an instance of _closedsocket and lets the GC clean up
the real socket. (See socket.py around line 160.)

This works fine with a reference counting GC, but can potentially leave
sockets hanging around for a long time on platforms (e.g. the CLR) with
other GC algorithms. It causes most of the socket unit tests to fail on
IronPython.

Is there a reason for this implementation?

This patch to _socketobject.close() makes socket.py work with
IronPython:

     def close(self):
+        if not isinstance(self._sock, _closedsocket):
+            self._sock.close()
         self._sock = _closedsocket()
         self.send = self.recv = self.sendto = self.recvfrom =
self._sock._dummy

--Bruce
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4