本文整理汇总了Python中urllib3.poolmanager.PoolManager.key_fn_by_scheme['http']方法的典型用法代码示例。如果您正苦于以下问题:Python PoolManager.key_fn_by_scheme['http']方法的具体用法?Python PoolManager.key_fn_by_scheme['http']怎么用?Python PoolManager.key_fn_by_scheme['http']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类urllib3.poolmanager.PoolManager
的用法示例。
在下文中一共展示了PoolManager.key_fn_by_scheme['http']方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_custom_pool_key
# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import key_fn_by_scheme['http'] [as 别名]
def test_custom_pool_key(self):
"""Assert it is possible to define a custom key function."""
p = PoolManager(10)
p.key_fn_by_scheme['http'] = lambda x: tuple(x['key'])
pool1 = p.connection_from_url(
'http://example.com', pool_kwargs={'key': 'value'})
pool2 = p.connection_from_url(
'http://example.com', pool_kwargs={'key': 'other'})
pool3 = p.connection_from_url(
'http://example.com', pool_kwargs={'key': 'value', 'x': 'y'})
assert 2 == len(p.pools)
assert pool1 is pool3
assert pool1 is not pool2
示例2: test_custom_pool_key
# 需要导入模块: from urllib3.poolmanager import PoolManager [as 别名]
# 或者: from urllib3.poolmanager.PoolManager import key_fn_by_scheme['http'] [as 别名]
def test_custom_pool_key(self):
"""Assert it is possible to define a custom key function."""
p = PoolManager(10)
self.addCleanup(p.clear)
p.key_fn_by_scheme['http'] = lambda x: tuple(x['key'])
pool1 = p.connection_from_url(
'http://example.com', pool_kwargs={'key': 'value'})
pool2 = p.connection_from_url(
'http://example.com', pool_kwargs={'key': 'other'})
pool3 = p.connection_from_url(
'http://example.com', pool_kwargs={'key': 'value', 'x': 'y'})
self.assertEqual(2, len(p.pools))
self.assertTrue(pool1 is pool3)
self.assertFalse(pool1 is pool2)