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


Python HTTPConnectionPool.from_url方法代码示例

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


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

示例1: pool_get

# 需要导入模块: from urllib3 import HTTPConnectionPool [as 别名]
# 或者: from urllib3.HTTPConnectionPool import from_url [as 别名]
def pool_get(url_list):
    assert url_list
    pool = HTTPConnectionPool.from_url(url_list[0])
    for url in url_list:
        now = time.time()
        r = pool.get_url(url)
        elapsed = time.time() - now
        print "Got in %0.3fs: %s" % (elapsed, url)
开发者ID:mozilla,项目名称:FlightDeck-lib,代码行数:10,代码来源:benchmark.py

示例2: EviscapeError

# 需要导入模块: from urllib3 import HTTPConnectionPool [as 别名]
# 或者: from urllib3.HTTPConnectionPool import from_url [as 别名]
API_URL = u'http://%s/api/%s/%s/' % (SERVER, API_VERSION, API_PROTOCOL)
API_DOCS = u'http://%s/api/%s/docs/' % (SERVER, API_VERSION)
API_RESPONSE_FORMAT = 'json' #this toolkit only support xml and json

signature_method = oauth.OAuthSignatureMethod_HMAC_SHA1()

REQUEST_TOKEN_URL = 'http://%s/oauth/request_token' % SERVER
ACCESS_TOKEN_URL = 'http://%s/oauth/access_token' % SERVER
AUTHORIZATION_URL = 'http://%s/oauth/authorize' % SERVER

CONSUMER_KEY = API_KEY
CONSUMER_SECRET = API_SECRET

CONSUMER = oauth.OAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET)

http_pool = HTTPConnectionPool.from_url(API_URL)


class EviscapeError(Exception):
    pass

def request_oauth_resource(consumer, url, access_token, parameters=None, signature_method=signature_method, http_method='GET'):
    """
    usage: request_oauth_resource( consumer, '/url/', your_access_token, parameters=dict() )
    Returns a OAuthRequest object
    """
    oauth_request = oauth.OAuthRequest.from_consumer_and_token(
        consumer, token=access_token, http_url=url, parameters=parameters, http_method=http_method
    )
    oauth_request.sign_request(signature_method, consumer, access_token)
    return oauth_request
开发者ID:musicpicturesltd,项目名称:pyEviscape,代码行数:33,代码来源:utils.py


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