Requests / urllib3错误:unorderable类型:Retry()< INT()

时间:2015-08-17 17:12:33

标签: session python-3.x subclass python-requests urllib3

我理解错误,但在我的代码上下文中却没有理解它。这是在Python 3.4中。相关的代码位(为了清晰起见,有些简化):

from requests.adapters import HTTPAdapter
from urllib3.poolmanager import PoolManager

class SessionAdapter(HTTPAdapter):

    def init_poolmanager(self, connections, maxsize, block=False):

        self.poolmanager = PoolManager(num_pools=connections,
                                        maxsize=maxsize,
                                        block=block,
                                        ssl_version=ssl.PROTOCOL_TLSv1,
                                        cert_reqs = 'CERT_REQUIRED',
                                        ca_certs = certifi.where(),
                                        )

try:

    app_session = requests.Session()

    app_session.mount('https://', SessionAdapter())

    app_response = app_session.post(
        url = 'https://<FQD URL>'
        , auth = (user, password)
        , verify = True
        )

    # Code errors on the previous line and never executes the logger line

    logger.debug('Status code: {}'.format(app_response.status_code))

    if app_response.status_code == 401:

        return 401

    else:

        return app_session

except:

    logger.debug('Exception')

sys.exc_info()我看到:

", verify = True"): unorderable types: Retry() < int()

如果错误类似于SessionAdapter() < int(),那么它可能更有意义。但我不知道Retry()检查的位置。

对于Python 3,是否需要以不同的方式导入PoolManager?我在Ubuntu上使用的是1.7.1版本的python-urllib3。

0 个答案:

没有答案