本文整理汇总了Python中requests.Session.timeout方法的典型用法代码示例。如果您正苦于以下问题:Python Session.timeout方法的具体用法?Python Session.timeout怎么用?Python Session.timeout使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类requests.Session
的用法示例。
在下文中一共展示了Session.timeout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import timeout [as 别名]
def __init__(self, env, id_correios, password,
cert=False, log_config=None, timeout=None):
''' Webservice initialization.
Depending on the env get a different wsdl definition.
New Correios SIGEP uses HTTPAuth to do requests.
Args:
env (str): Environment used to get the wsdl
id_correios (str): IdCorreios given by correios website
password (str): password vinculated to the IdCorreios
log_config (dict): Dictionary configurations of logging
'''
''' Untrusted ssl certificate for homolog envs see more at:
https://www.ssllabs.com/ssltest/analyze.html?d=apphom.correios.com.br
'''
if cert is False:
verify = False
else:
verify = certifi.where()
self.timeout = timeout or 300
if log_config is not None and isinstance(log_config, dict):
""" Example config from zeep documentation:
{
'version': 1,
'formatters': {
'verbose': {
'format': '%(name)s: %(message)s'
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
},
},
'loggers': {
'zeep.transports': {
'level': 'DEBUG',
'propagate': True,
'handlers': ['console'],
},
}
}
"""
logging.config.dictConfig(log_config)
session = Session()
session.timeout = self.timeout
session.verify = verify
session.auth=(id_correios, password)
t = Transport(session=session);
self.client = Client(wsdl=self.get_env(env), transport=t)
示例2: __init__
# 需要导入模块: from requests import Session [as 别名]
# 或者: from requests.Session import timeout [as 别名]
def __init__(self, wsdl, cert=None, verify=True, timeout=8, **kwargs):
session = Session()
session.cert = cert
session.verify = verify
session.timeout = timeout
session.headers.update({'Content-Type': 'text/xml;charset=UTF-8'})
transport = Transport(
operation_timeout=timeout,
session=session
)
super().__init__(wsdl=wsdl, transport=transport, **kwargs)