本文整理汇总了Python中slimta.util.dns.DNSResolver._wait_channel方法的典型用法代码示例。如果您正苦于以下问题:Python DNSResolver._wait_channel方法的具体用法?Python DNSResolver._wait_channel怎么用?Python DNSResolver._wait_channel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类slimta.util.dns.DNSResolver
的用法示例。
在下文中一共展示了DNSResolver._wait_channel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wait_channel_error
# 需要导入模块: from slimta.util.dns import DNSResolver [as 别名]
# 或者: from slimta.util.dns.DNSResolver import _wait_channel [as 别名]
def test_wait_channel_error(self):
DNSResolver._channel = channel = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(select, 'select')
channel.getsock().AndReturn(('read', 'write'))
channel.timeout().AndReturn(1.0)
select.select('read', 'write', [], 1.0).AndRaise(ValueError(13))
channel.cancel()
self.mox.ReplayAll()
with self.assertRaises(ValueError):
DNSResolver._wait_channel()
self.assertIsNone(DNSResolver._channel)
示例2: test_wait_channel
# 需要导入模块: from slimta.util.dns import DNSResolver [as 别名]
# 或者: from slimta.util.dns.DNSResolver import _wait_channel [as 别名]
def test_wait_channel(self):
DNSResolver._channel = channel = self.mox.CreateMockAnything()
self.mox.StubOutWithMock(select, 'select')
channel.getsock().AndReturn(('read', 'write'))
channel.timeout().AndReturn(1.0)
select.select('read', 'write', [], 1.0).AndReturn(
([1, 2, 3], [4, 5, 6], None))
for fd in [1, 2, 3]:
channel.process_fd(fd, pycares.ARES_SOCKET_BAD)
for fd in [4, 5, 6]:
channel.process_fd(pycares.ARES_SOCKET_BAD, fd)
channel.getsock().AndReturn(('read', 'write'))
channel.timeout().AndReturn(None)
channel.process_fd(pycares.ARES_SOCKET_BAD, pycares.ARES_SOCKET_BAD)
channel.getsock().AndReturn((None, None))
self.mox.ReplayAll()
DNSResolver._wait_channel()