下面是soa接口调用的核心代码

#! /usr/bin/python
# coding:utf-8
from suds.client import Client
def SoaRequest(wsdl,fnname,data):
soaService = Client(wsdl).service
soaRep = getattr(soaService,fnname)(data)
return soaRep

问题就这样出现了:

我调用一个接口,总是报错,见下图:

之后Debug断点定位到suds模块的sxbasic.py文件中的Import类的open方法

    def open(self, options):"""
Open and import the refrenced schema.
@param options: An options dictionary.
@type options: L{options.Options}
@return: The referenced schema.
@rtype: L{Schema}
"""
if self.opened:
return
self.opened = True
log.debug('%s, importing ns="%s", location="%s"', self.id, self.ns[1], self.location)
result = self.locate() if result is None:
if self.location is None:
log.debug('imported schema (%s) not-found', self.ns[1])
else:
result = self.download(options)
log.debug('imported:\n%s', result)
return result
self.location 为None时日志打印,否则就执行download
而我测试的接口有个这种问题,A中依赖B,B中依赖C,C中依赖A,循环依赖
运行后控制台就会报错:
RuntimeError: maximum recursion depth exceeded 是不是递归深度不够呢(个人觉得循环的话,深度再大有什么用了)
import sys
sys.setrecursionlimit(1000000)

设置100万的递归深度,再运行直接 stack overflow,溢出了

好吧,那就改吧
在类Import外定义数组变量resultList = [] 
   def open(self, options):
global resultList
if self.opened:
return
self.opened = True
log.debug('%s, importing ns="%s", location="%s"', self.id, self.ns[1], self.location)
result = self.locate() if result is None:
if self.location is None:
log.debug('imported schema (%s) not-found', self.ns[1])
else:
if self.location in resultList:    #若location存在List中,则打印debug日志,不加载options
log.debug('location is already in resultList')
else:
resultList.append(self.location)  #location不存在时,List中append后,加载options
result = self.download(options)
log.debug('imported:\n%s', result)
return result

去除了循环依赖,出现另外一个问题:

先看下我soap接口的通用调用方法:

#! /usr/bin/python
# coding:utf-8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
from suds.client import Clientdef SoaRequest(wsdl,fnname,data): #soap接口调用方法
soaService = Client(wsdl).service
soaRep = getattr(soaService,fnname)(data)
return soaRep

通过这个方法去逐行调用excel中的用例参数,来实现数据驱动的接口自动化框架

但是单个接口,多组参数用例的组合场景,运用上面的脚本后就报错

Type not found.......

考虑到可能是因为第一行用例执行过程中,在List中append 进location,到执行第二条用例的时候,由于和第一行用例的接口是一样的,故而List判断中就没有进入到download分支,所以就抛出了not found的异常

解决方法是在执行用例前,清空list

改造soap接口核心调用程序

#! /usr/bin/python
# coding:utf-8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
from suds.client import Client
from suds.xsd import sxbasic
def SoaRequest(wsdl,fnname,data): #soap接口调用方法
sxbasic.resultList=[] #初始化location列表
soaService = Client(wsdl).service
soaRep = getattr(soaService,fnname)(data)
return soaRep

这样就万事大吉了

如果有人有更好的解决方案,更简便的处理方法,欢迎沟通交流 本人邮箱:270193176@qq.com

记 suds 模块循环依赖的坑-RuntimeError: maximum recursion depth exceeded的更多相关文章

  1. Python递归报错:RuntimeError: maximum recursion depth exceeded in comparison

    Python中默认的最大递归深度是989,当尝试递归第990时便出现递归深度超限的错误: RuntimeError: maximum recursion depth exceeded in compa ...

  2. python递归深度报错--RuntimeError: maximum recursion depth exceeded

    当你的程序递归的次数超过999次的时候,就会引发RuntimeError: maximum recursion depth exceeded. 解决方法两个: 1.增加系统的递归调用的次数: impo ...

  3. scrapy RuntimeError: maximum recursion depth exceeded while calling a Python object 超出python最大递归数异常

    2019-10-21 19:01:00 [scrapy.core.engine] INFO: Spider opened2019-10-21 19:01:00 [scrapy.extensions.l ...

  4. 函数递归时,递归次数到900多时,就是抛出异常exception RuntimeError('maximum recursion depth exceeded',)

    import subprocess import multiprocessing import urllib import sys import os import pymongo import si ...

  5. 这个 Spring 循环依赖的坑,90% 以上的人都不知道

    1. 前言 这两天工作遇到了一个挺有意思的Spring循环依赖的问题,但是这个和以往遇到的循环依赖问题都不太一样,隐藏的相当隐蔽,网络上也很少看到有其他人遇到类似的问题.这里权且称他非典型Spring ...

  6. 一起来踩踩 Spring 中这个循环依赖的坑

    1. 前言 2. 典型场景 3. 什么是依赖 4. 什么是依赖调解 5. 为什么要依赖注入 6. Spring的依赖注入模型 7. 非典型问题 参考资料 1. 前言 这两天工作遇到了一个挺有意思的Sp ...

  7. RequireJS 循环依赖报 模块undefined 处理方案

    RequireJS 循环依赖 开始学习使用RequireJS之后做了几个小例子,之后想着把手头的项目也用RequireJS写一遍试试.感觉胜利就在前方了,忽然发现始终卡在一个问题上: 很常见的一个问题 ...

  8. kmdjs和循环依赖

    循环依赖 循环依赖是非常必要的,有的程序写着写着就循环依赖了,可以提取出一个对象来共同依赖解决循环依赖,但是有时会破坏程序的逻辑自封闭和高内聚.所以没解决好循环依赖的模块化库.框架.编译器都不是一个好 ...

  9. seaJS循环依赖的解决原理

    seajs模块的六个状态. var STATUS = {  'FETCHING': 1, // The module file is fetching now. 模块正在下载中  'FETCHED': ...

随机推荐

  1. 如何利用express新建项目(上)

    如何利用express新建项目(上) 摘要 这篇文章将讲解了如何快速利用express新建项目 一.express4.x的安装 1. npm install -g express 2. npm ins ...

  2. nRF51800 蓝牙学习 进程记录 1:感想

    一直想开一个高大上点的博客,觉得博客园不错,便申请了.一直没时间看,都快忘了,无意间登上提示申请到了.便写个东西看看. 正在学习nRF51822的蓝牙开发板,为了做毕设准备.备考中,一直没时间学,但今 ...

  3. arcpy.mapping常用四大件-MapDocument

    arcpy.mapping常用四大件-MapDocument by 李远祥 点开arcpy.mapping的帮助,可以看到其有限的几个类,看起来东西不是很多,但却是非常的使用.由于arcpy定位就是粗 ...

  4. Ubuntu 14.04 64bit 系统下打开PHPadmin时出现缺少mysqli|mysql 扩展的解决方法(php5)

    网上找了很多方法,都是翻来覆去的抄袭. 都在说把 /etc/php5/apache2/php.ini 下面的  ;extension=php_mysqli.dll  前面的 ; 注释符号去掉 再重启 ...

  5. 使用LVS实现负载均衡原理及安装配置详解

    负载均衡集群是 load balance 集群的简写,翻译成中文就是负载均衡集群.常用的负载均衡开源软件有nginx.lvs.haproxy,商业的硬件负载均衡设备F5.Netscale.这里主要是学 ...

  6. javascript的方法

    1. decodeURIComponent() decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码. 语法: decodeURI ...

  7. win7下安装maven3.1.1

    1.下载maven的安装包,下载地址http://maven.apache.org/download.cgi ,在这个页面中,你可以选择要下载的最新版本的maven gz包.我下载的是maven3.1 ...

  8. oracle 随笔

    oracle分页 select * from (select a1.*, rownum rn from (select *from emp) a1 where rownum<=10) where ...

  9. BZOJ 2142: 礼物

    模非素数下的排列组合,简直凶残 调着调着就过了= = 都不知道怎么过的= = 直接上链接http://hi.baidu.com/aekdycoin/blog/item/147620832b567eb4 ...

  10. 纪中集训 Day 7

    今天超级不爽啊啊啊啊 尼玛我三道题都想出来了就是没对一道,第一题没理负数尼玛题目没告诉我,第二题尼玛题目也没说最近的点是第(l+r)/2而不是距离为(a[l]+a[r])/2啊啊啊啊,第三题没打GCD ...