本文整理汇总了Python中twisted.internet.interfaces.IHalfCloseableProtocol方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IHalfCloseableProtocol方法的具体用法?Python interfaces.IHalfCloseableProtocol怎么用?Python interfaces.IHalfCloseableProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.interfaces
的用法示例。
在下文中一共展示了interfaces.IHalfCloseableProtocol方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def __init__(self, connectedDeferred, wrappedProtocol):
"""
@param connectedDeferred: The L{Deferred} that will callback
with the C{wrappedProtocol} when it is connected.
@param wrappedProtocol: An L{IProtocol} provider that will be
connected.
"""
self._connectedDeferred = connectedDeferred
self._wrappedProtocol = wrappedProtocol
for iface in [interfaces.IHalfCloseableProtocol,
interfaces.IFileDescriptorReceiver,
interfaces.IHandshakeListener]:
if iface.providedBy(self._wrappedProtocol):
directlyProvides(self, iface)
示例2: _handleRawStream
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def _handleRawStream(self):
"""
Switch the current connection to be a "hijacked" aka raw stream: one
where bytes just get naively proxied back and forth.
"""
def loseWriteConnectionReason(reason):
# discard the reason, for compatibility with readConnectionLost
self.transport.loseWriteConnection()
self.father.transport.readConnectionLost = loseWriteConnectionReason
directlyProvides(self.father.transport, IHalfCloseableProtocol)
self.http = False
self.father.transport.write(
"HTTP/1.1 200 OK\r\n"
"Content-Type: application/vnd.docker.raw-stream\r\n"
"\r\n")
def stdinHandler(data):
self.transport.write(data)
self.father.transport.protocol.dataReceived = stdinHandler
self.setStreamingMode(True)
示例3: _closeWriteConnection
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def _closeWriteConnection(self):
try:
self.socket.shutdown(1)
except socket.error:
pass
p = interfaces.IHalfCloseableProtocol(self.protocol, None)
if p:
try:
p.writeConnectionLost()
except:
f = failure.Failure()
log.err()
self.connectionLost(f)
示例4: readConnectionLost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def readConnectionLost(self, reason):
p = interfaces.IHalfCloseableProtocol(self.protocol, None)
if p:
try:
p.readConnectionLost()
except:
log.err()
self.connectionLost(failure.Failure())
else:
self.connectionLost(reason)
示例5: _writeConnectionLost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def _writeConnectionLost(self, reason):
self._writer=None
if self.disconnecting:
self.connectionLost(reason)
return
p = interfaces.IHalfCloseableProtocol(self.protocol, None)
if p:
try:
p.writeConnectionLost()
except:
log.err()
self.connectionLost(failure.Failure())
示例6: readConnectionLost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def readConnectionLost(self):
"""
Proxy L{IHalfCloseableProtocol.readConnectionLost} to our
C{self._wrappedProtocol}
"""
self._wrappedProtocol.readConnectionLost()
示例7: writeConnectionLost
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def writeConnectionLost(self):
"""
Proxy L{IHalfCloseableProtocol.writeConnectionLost} to our
C{self._wrappedProtocol}
"""
self._wrappedProtocol.writeConnectionLost()
示例8: test_wrappingProtocolNotFileDescriptorReceiver
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def test_wrappingProtocolNotFileDescriptorReceiver(self):
"""
Our L{_WrappingProtocol} does not provide L{IHalfCloseableProtocol} if
the wrapped protocol doesn't.
"""
tp = TestProtocol()
p = endpoints._WrappingProtocol(None, tp)
self.assertFalse(interfaces.IFileDescriptorReceiver.providedBy(p))
示例9: test_wrappingProtocolHalfCloseable
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def test_wrappingProtocolHalfCloseable(self):
"""
Our L{_WrappingProtocol} should be an L{IHalfCloseableProtocol} if the
C{wrappedProtocol} is.
"""
cd = object()
hcp = TestHalfCloseableProtocol()
p = endpoints._WrappingProtocol(cd, hcp)
self.assertEqual(
interfaces.IHalfCloseableProtocol.providedBy(p), True)
示例10: make_sc
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def make_sc(set_protocol=True, half_closeable=False):
scid = 4
hostaddr = _WormholeAddress()
peeraddr = _SubchannelAddress(scid)
m = mock_manager()
sc = SubChannel(scid, m, hostaddr, peeraddr)
p = mock.Mock()
if half_closeable:
directlyProvides(p, IHalfCloseableProtocol)
if set_protocol:
sc._set_protocol(p)
return sc, m, scid, hostaddr, peeraddr, p
示例11: _closeWriteConnection
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def _closeWriteConnection(self):
try:
getattr(self.socket, self._socketShutdownMethod)(1)
except socket.error:
pass
p = interfaces.IHalfCloseableProtocol(self.protocol, None)
if p:
try:
p.writeConnectionLost()
except:
f = failure.Failure()
log.err()
self.connectionLost(f)
示例12: __init__
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IHalfCloseableProtocol [as 别名]
def __init__(self, connectedDeferred, wrappedProtocol):
"""
@param connectedDeferred: The L{Deferred} that will callback
with the C{wrappedProtocol} when it is connected.
@param wrappedProtocol: An L{IProtocol} provider that will be
connected.
"""
self._connectedDeferred = connectedDeferred
self._wrappedProtocol = wrappedProtocol
if interfaces.IHalfCloseableProtocol.providedBy(
self._wrappedProtocol):
directlyProvides(self, interfaces.IHalfCloseableProtocol)