本文整理汇总了Python中twisted.internet.interfaces.IListeningPort方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IListeningPort方法的具体用法?Python interfaces.IListeningPort怎么用?Python interfaces.IListeningPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.interfaces
的用法示例。
在下文中一共展示了interfaces.IListeningPort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_stopService
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IListeningPort [as 别名]
def test_stopService(self):
"""
L{StreamServerEndpointService.stopService} calls C{stopListening} on
the L{IListeningPort} returned from its endpoint, returns the
C{Deferred} from stopService, and sets C{running} to C{False}.
"""
self.svc.privilegedStartService()
self.fakeServer.startedListening()
# Ensure running gets set to true
self.svc.startService()
result = self.svc.stopService()
l = []
result.addCallback(l.append)
self.assertEquals(len(l), 0)
self.fakeServer.stoppedListening()
self.assertEquals(len(l), 1)
self.assertFalse(self.svc.running)
示例2: test_interface
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IListeningPort [as 别名]
def test_interface(self):
"""
A L{TuntapPort} instance provides L{IListeningPort}.
"""
port = TuntapPort(b"device", EthernetProtocol())
self.assertTrue(verifyObject(IListeningPort, port))
示例3: _stopPort
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IListeningPort [as 别名]
def _stopPort(self, port):
"""
Verify that the C{stopListening} method of an L{IListeningPort} removes
that port from the reactor's "readers" set and also that the
L{Deferred} returned by that method fires with L{None}.
@param port: The port object to stop.
@type port: L{IListeningPort} provider
"""
stopped = port.stopListening()
self.assertNotIn(port, self.reactor.getReaders())
# An unfortunate implementation detail
self.reactor.advance(0)
self.assertIsNone(self.successResultOf(stopped))
示例4: test_interface
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IListeningPort [as 别名]
def test_interface(self):
"""
L{IReactorUDP.listenUDP} returns an object providing L{IListeningPort}.
"""
reactor = self.buildReactor()
port = reactor.listenUDP(0, DatagramProtocol())
self.assertTrue(verifyObject(IListeningPort, port))