summaryrefslogtreecommitdiff
path: root/Lib/socket.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2009-01-12 04:50:11 +0000
committerGregory P. Smith <greg@mad-scientist.com>2009-01-12 04:50:11 +0000
commitde3369f2ca0e2e1b26482a34fdc09d18a3a928d9 (patch)
tree65d355ce55f2c3d4c4ff507b7d7a5436b7cf82f5 /Lib/socket.py
parentce36962d12b78ede24b71d5ac1075109f5e23787 (diff)
downloadcpython-git-de3369f2ca0e2e1b26482a34fdc09d18a3a928d9.tar.gz
Fixes issue #3826 and #4791:
Have SocketIO objects update their reference count in the underlying socket object on close() so that the underlying socket object is closed immediately when the last user is done rather than at an unknown later time when garbage collection can do it.
Diffstat (limited to 'Lib/socket.py')
-rw-r--r--Lib/socket.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/socket.py b/Lib/socket.py
index 045987c086..737930d003 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -225,11 +225,12 @@ class SocketIO(io.RawIOBase):
return self._writing and not self.closed
def fileno(self):
+ self._checkClosed()
return self._sock.fileno()
@property
def name(self):
- return self._sock.fileno()
+ return self.fileno()
@property
def mode(self):
@@ -239,9 +240,12 @@ class SocketIO(io.RawIOBase):
if self.closed:
return
io.RawIOBase.close(self)
+ self._sock._decref_socketios()
+ self._sock = None
def __del__(self):
- self._sock._decref_socketios()
+ if not self.closed:
+ self._sock._decref_socketios()
def getfqdn(name=''):