python suds.client Client 设置超时时间

看suds的源码后,没有发现timeout,但是发现了set_options函数,具体代码如下:

class Client(UnicodeMixin):
    
    # ....
    def __init__(self, url, **kwargs):
        """
        @param url: The URL for the WSDL.
        @type url: str
        @param kwargs: keyword arguments.
        @see: L{Options}

        """
        options = Options()
        options.transport = suds.transport.https.HttpAuthenticated()
        self.options = options
        if "cache" not in kwargs:
            kwargs["cache"] = suds.cache.ObjectCache(days=1)
        self.set_options(**kwargs)
        reader = DefinitionsReader(options, Definitions)
        self.wsdl = reader.open(url)
        plugins = PluginContainer(options.plugins)
        plugins.init.initialized(wsdl=self.wsdl)
        self.factory = Factory(self.wsdl)
        self.service = ServiceSelector(self, self.wsdl.services)
        self.sd = []
        for s in self.wsdl.services:
            sd = ServiceDefinition(self.wsdl, s)
            self.sd.append(sd)

    def set_options(self, **kwargs):
        """
        Set options.

        @param kwargs: keyword arguments.
        @see: L{Options}

        """
        p = Unskin(self.options)
        p.update(kwargs)
        #下面这个debug是我加的
        log.debug("set_options = %s", p)

先创建client对象,执行下面的操作:

>>> client.set_options(timeout=120)
DEBUG:suds.client:set_options = Definitions:
        prettyxml: classes=(<type 'bool'>,), default=False
        cachingpolicy: classes=(<type 'int'>,), default=0
        soapheaders: classes=*, default=()
        documentStore: classes=(<class 'suds.store.DocumentStore'>,), default=<suds.store.DocumentStore object at 0x7f3378bc7fd0>
        extraArgumentErrors: classes=(<type 'bool'>,), default=True
        service: classes=(<type 'int'>, <type 'basestring'>), default=None
        doctor: classes=(<class suds.xsd.doctor.Doctor at 0x7f3378bcd258>,), default=None
        cache: classes=(<class 'suds.cache.Cache'>,), default=<suds.cache.NoCache object at 0x7f3377e23450>
        retxml: classes=(<type 'bool'>,), default=False
        prefixes: classes=(<type 'bool'>,), default=True
        faults: classes=(<type 'bool'>,), default=True
        wsse: classes=(<class 'suds.wsse.Security'>,), default=None
        autoblend: classes=(<type 'bool'>,), default=False
        location: classes=(<type 'basestring'>,), default=None
        plugins: classes=(<type 'list'>, <type 'tuple'>), default=[]
        unwrap: classes=(<type 'bool'>,), default=True
        xstq: classes=(<type 'bool'>,), default=True
        port: classes=(<type 'int'>, <type 'basestring'>), default=None
        transport: classes=(<class 'suds.transport.Transport'>,), default=None
        nosend: classes=(<type 'bool'>,), default=False
Content:
        ('cachingpolicy', 0)
        ('soapheaders', ())
        ('cache', <suds.cache.ObjectCache object at 0x7f3377bbc7d0>)
        ('extraArgumentErrors', True)
        ('service', None)
        ('doctor', None)
        ('documentStore', <suds.store.DocumentStore object at 0x7f3378bc7fd0>)
        ('port', None)
        ('prefixes', True)
        ('faults', True)
        ('wsse', None)
        ('autoblend', False)
        ('location', None)
        ('nosend', False)
        ('plugins', [])
        ('unwrap', True)
        ('prettyxml', False)
        ('retxml', False)
        ('transport', <suds.transport.https.HttpAuthenticated object at 0x7f3377bbc490>)
        ('xstq', True)
Linked:
Definitions:
        username: classes=(<type 'basestring'>,), default=None
        headers: classes=(<type 'dict'>,), default={}
        password: classes=(<type 'basestring'>,), default=None
        proxy: classes=(<type 'dict'>,), default={}
        timeout: classes=(<type 'int'>, <type 'float'>), default=90
Content:
        ('username', 'admin')
        ('headers', {})
        ('password', 'admin_default')
        ('proxy', {})
        ('timeout', 120)
Linked:
Definitions:
        prettyxml: classes=(<type 'bool'>,), default=False
        cachingpolicy: classes=(<type 'int'>,), default=0
        soapheaders: classes=*, default=()
        documentStore: classes=(<class 'suds.store.DocumentStore'>,), default=<suds.store.DocumentStore object at 0x7f3378bc7fd0>
        extraArgumentErrors: classes=(<type 'bool'>,), default=True
        service: classes=(<type 'int'>, <type 'basestring'>), default=None
        doctor: classes=(<class suds.xsd.doctor.Doctor at 0x7f3378bcd258>,), default=None
        cache: classes=(<class 'suds.cache.Cache'>,), default=<suds.cache.NoCache object at 0x7f3377e23450>
        retxml: classes=(<type 'bool'>,), default=False
        prefixes: classes=(<type 'bool'>,), default=True
        faults: classes=(<type 'bool'>,), default=True
        wsse: classes=(<class 'suds.wsse.Security'>,), default=None
        autoblend: classes=(<type 'bool'>,), default=False
        location: classes=(<type 'basestring'>,), default=None
        plugins: classes=(<type 'list'>, <type 'tuple'>), default=[]
        unwrap: classes=(<type 'bool'>,), default=True
        xstq: classes=(<type 'bool'>,), default=True
        port: classes=(<type 'int'>, <type 'basestring'>), default=None
        transport: classes=(<class 'suds.transport.Transport'>,), default=None
        nosend: classes=(<type 'bool'>,), default=False
Content:
        ('cachingpolicy', 0)
        ('soapheaders', ())
        ('cache', <suds.cache.ObjectCache object at 0x7f3377bbc7d0>)
        ('extraArgumentErrors', True)
        ('service', None)
        ('doctor', None)
        ('documentStore', <suds.store.DocumentStore object at 0x7f3378bc7fd0>)
        ('port', None)
        ('prefixes', True)
        ('faults', True)
        ('wsse', None)
        ('autoblend', False)
        ('location', None)
        ('nosend', False)
        ('plugins', [])
        ('unwrap', True)
        ('prettyxml', False)
        ('retxml', False)
        ('transport', <suds.transport.https.HttpAuthenticated object at 0x7f3377bbc490>)
        ('xstq', True)

timeout默认为90秒。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值