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.
This commit is contained in:
Gregory P. Smith 2009-01-12 04:50:11 +00:00
parent ce36962d12
commit de3369f2ca
3 changed files with 43 additions and 2 deletions

View file

@ -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=''):