add getpeername() call to make asyncore work better
This commit is contained in:
parent
2853a7ae05
commit
619192814d
|
@ -433,6 +433,18 @@ class Channel (object):
|
||||||
else:
|
else:
|
||||||
self.settimeout(0.0)
|
self.settimeout(0.0)
|
||||||
|
|
||||||
|
def getpeername(self):
|
||||||
|
"""
|
||||||
|
Return the address of the remote side of this Channel, if possible.
|
||||||
|
This is just a wrapper around C{'getpeername'} on the Transport, used
|
||||||
|
to provide enough of a socket-like interface to allow asyncore to work.
|
||||||
|
(asyncore likes to call C{'getpeername'}.)
|
||||||
|
|
||||||
|
@return: the address if the remote host, if known
|
||||||
|
@rtype: tuple(str, int)
|
||||||
|
"""
|
||||||
|
return self.transport.getpeername()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
"""
|
"""
|
||||||
Close the channel. All future read/write operations on the channel
|
Close the channel. All future read/write operations on the channel
|
||||||
|
|
|
@ -1211,6 +1211,21 @@ class Transport (threading.Thread):
|
||||||
else:
|
else:
|
||||||
self._preferred_compression = ( 'none', )
|
self._preferred_compression = ( 'none', )
|
||||||
|
|
||||||
|
def getpeername(self):
|
||||||
|
"""
|
||||||
|
Return the address of the remote side of this Transport, if possible.
|
||||||
|
This is effectively a wrapper around C{'getpeername'} on the underlying
|
||||||
|
socket. If the socket-like object has no C{'getpeername'} method,
|
||||||
|
then C{("unknown", 0)} is returned.
|
||||||
|
|
||||||
|
@return: the address if the remote host, if known
|
||||||
|
@rtype: tuple(str, int)
|
||||||
|
"""
|
||||||
|
gp = getattr(self.sock, 'getpeername', None)
|
||||||
|
if gp is None:
|
||||||
|
return ('unknown', 0)
|
||||||
|
return gp()
|
||||||
|
|
||||||
def stop_thread(self):
|
def stop_thread(self):
|
||||||
self.active = False
|
self.active = False
|
||||||
self.packetizer.close()
|
self.packetizer.close()
|
||||||
|
|
Loading…
Reference in New Issue