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


Python dns.DNSQueryTimeoutError方法代码示例

本文整理汇总了Python中twisted.names.dns.DNSQueryTimeoutError方法的典型用法代码示例。如果您正苦于以下问题:Python dns.DNSQueryTimeoutError方法的具体用法?Python dns.DNSQueryTimeoutError怎么用?Python dns.DNSQueryTimeoutError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.names.dns的用法示例。


在下文中一共展示了dns.DNSQueryTimeoutError方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getHostByName

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def getHostByName(name, timeout=None, effort=10):
    """
    Resolve a name to a valid ipv4 or ipv6 address.

    Will errback with C{DNSQueryTimeoutError} on a timeout, C{DomainError} or
    C{AuthoritativeDomainError} (or subclasses) on other errors.

    @type name: C{str}
    @param name: DNS name to resolve.

    @type timeout: Sequence of C{int}
    @param timeout: Number of seconds after which to reissue the query.
    When the last timeout expires, the query is considered failed.

    @type effort: C{int}
    @param effort: How many times CNAME and NS records to follow while
    resolving this name.

    @rtype: C{Deferred}
    """
    return getResolver().getHostByName(name, timeout, effort) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:client.py

示例2: test_queryTimeout

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def test_queryTimeout(self):
        """
        Test that query timeouts after some seconds.
        """
        d = self.proto.query(('127.0.0.1', 21345), [dns.Query(b'foo')])
        self.assertEqual(len(self.proto.liveMessages), 1)
        self.clock.advance(10)
        self.assertFailure(d, dns.DNSQueryTimeoutError)
        self.assertEqual(len(self.proto.liveMessages), 0)
        return d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:12,代码来源:test_dns.py

示例3: _reissue

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def _reissue(self, reason, addressesLeft, addressesUsed, query, timeout):
        reason.trap(dns.DNSQueryTimeoutError)

        # If there are no servers left to be tried, adjust the timeout
        # to the next longest timeout period and move all the
        # "used" addresses back to the list of addresses to try.
        if not addressesLeft:
            addressesLeft = addressesUsed
            addressesLeft.reverse()
            addressesUsed = []
            timeout = timeout[1:]

        # If all timeout values have been used this query has failed.  Tell the
        # protocol we're giving up on it and return a terminal timeout failure
        # to our caller.
        if not timeout:
            return failure.Failure(defer.TimeoutError(query))

        # Get an address to try.  Take it out of the list of addresses
        # to try and put it ino the list of already tried addresses.
        address = addressesLeft.pop()
        addressesUsed.append(address)

        # Issue a query to a server.  Use the current timeout.  Add this
        # function as a timeout errback in case another retry is required.
        d = self._query(address, query, timeout[0], reason.value.id)
        d.addErrback(self._reissue, addressesLeft, addressesUsed, query, timeout)
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:30,代码来源:client.py

示例4: query

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def query(self, address, queries, timeout=10, id=None):
        self.queries.append((address, queries, timeout, id))
        return defer.fail(dns.DNSQueryTimeoutError(queries)) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:5,代码来源:test_names.py

示例5: test_queryTimeout

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def test_queryTimeout(self):
        """
        Test that query timeouts after some seconds.
        """
        d = self.proto.query(('127.0.0.1', 21345), [dns.Query('foo')])
        self.assertEquals(len(self.proto.liveMessages), 1)
        self.clock.advance(10)
        self.assertFailure(d, dns.DNSQueryTimeoutError)
        self.assertEquals(len(self.proto.liveMessages), 0)
        return d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:test_dns.py

示例6: _reissue

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def _reissue(self, reason, addressesLeft, addressesUsed, query, timeout):
        reason.trap(dns.DNSQueryTimeoutError)

        # If there are no servers left to be tried, adjust the timeout
        # to the next longest timeout period and move all the
        # "used" addresses back to the list of addresses to try.
        if not addressesLeft:
            addressesLeft = addressesUsed
            addressesLeft.reverse()
            addressesUsed = []
            timeout = timeout[1:]

        # If all timeout values have been used, or the protocol has no
        # transport, this query has failed.  Tell the protocol we're
        # giving up on it and return a terminal timeout failure to our
        # caller.
        if not timeout or self.protocol.transport is None:
            self.protocol.removeResend(reason.value.id)
            return failure.Failure(defer.TimeoutError(query))

        # Get an address to try.  Take it out of the list of addresses
        # to try and put it ino the list of already tried addresses.
        address = addressesLeft.pop()
        addressesUsed.append(address)

        # Issue a query to a server.  Use the current timeout.  Add this
        # function as a timeout errback in case another retry is required.
        d = self.protocol.query(address, query, timeout[0], reason.value.id)
        d.addErrback(self._reissue, addressesLeft, addressesUsed, query, timeout)
        return d 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:32,代码来源:client.py

示例7: _reissue

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def _reissue(self, reason, address, query, timeout):
        reason.trap(dns.DNSQueryTimeoutError)
        log.msg('Retrying for %r' % query)
        d = self._query(address, query, timeout, reason.value.id)
        d.addErrback(self._timeout, query)
        return d 
开发者ID:skyline75489,项目名称:SimpleDNS,代码行数:8,代码来源:dnsproxy.py

示例8: _timeout

# 需要导入模块: from twisted.names import dns [as 别名]
# 或者: from twisted.names.dns import DNSQueryTimeoutError [as 别名]
def _timeout(self, reason, query):
        reason.trap(dns.DNSQueryTimeoutError)
        log.msg('Timeout for %r' % query)
        log.msg('Given up')
        return failure.Failure(defer.TimeoutError(query)) 
开发者ID:skyline75489,项目名称:SimpleDNS,代码行数:7,代码来源:dnsproxy.py


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