当前位置: 首页>>代码示例>>Python>>正文


Python interfaces.IHalfCloseableProtocol方法代码示例

本文整理汇总了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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:18,代码来源:endpoints.py

示例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) 
开发者ID:ClusterHQ,项目名称:powerstrip,代码行数:21,代码来源:powerstrip.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:tcp.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:tcp.py

示例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()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:15,代码来源:_posixstdio.py

示例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() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:endpoints.py

示例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() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:8,代码来源:endpoints.py

示例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)) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:10,代码来源:test_endpoints.py

示例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) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_endpoints.py

示例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 
开发者ID:warner,项目名称:magic-wormhole,代码行数:14,代码来源:test_subchannel.py

示例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) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:15,代码来源:tcp.py

示例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) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:16,代码来源:endpoints.py


注:本文中的twisted.internet.interfaces.IHalfCloseableProtocol方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。