本文整理匯總了Python中pycurl.TIMEOUT_MS屬性的典型用法代碼示例。如果您正苦於以下問題:Python pycurl.TIMEOUT_MS屬性的具體用法?Python pycurl.TIMEOUT_MS怎麽用?Python pycurl.TIMEOUT_MS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類pycurl
的用法示例。
在下文中一共展示了pycurl.TIMEOUT_MS屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: import pycurl [as 別名]
# 或者: from pycurl import TIMEOUT_MS [as 別名]
def __init__(self, url, params, bind, timeout, allow_redirects, headers, verify_keys):
"""Constructor"""
self.curl = pycurl.Curl()
full_url = url if params is None else "%s?%s" % (url, urllib.urlencode(params))
self.curl.setopt(pycurl.URL, str(full_url))
if bind is not None:
self.curl.setopt(pycurl.INTERFACE, str(bind))
self.curl.setopt(pycurl.FOLLOWLOCATION, allow_redirects)
if headers is not None:
self.curl.setopt(pycurl.HTTPHEADER, [
"%s: %s" % (str(key), str(value))
for (key, value) in headers.items()
])
if timeout is not None:
self.curl.setopt(pycurl.TIMEOUT_MS, int(timeout * 1000.0))
self.curl.setopt(pycurl.SSL_VERIFYHOST, verify_keys)
self.curl.setopt(pycurl.SSL_VERIFYPEER, verify_keys)
self.buf = StringIO.StringIO()
self.curl.setopt(pycurl.WRITEFUNCTION, self.buf.write)