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


Python Session.timeout方法代码示例

本文整理汇总了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)
开发者ID:trocafone,项目名称:correios-lib,代码行数:62,代码来源:base.py

示例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)
开发者ID:solidarium,项目名称:correios,代码行数:15,代码来源:soap.py


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