下面是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. [心得]传统IT转互联网面试经验分享

    http://www.newsmth.net/bbstcon.php?board=Java&gid=374779 传统IT外企干了8年,两年前转互联网的,面的和被面的都不少.这几天项目空档期, ...

  2. flask蓝图的使用

    首先,我对蓝图的理解相对通俗,就是觉得蓝图对于视图方法模块化.大项目协同开发过程中的一个很好的工具. 1.下图是我们通常情况下使用的项目组织结构

  3. .Net程序员学用Oracle系列(12):增删改查

    1.插入语句 1.1.INSERT 1.2.INSERT ALL 2.删除语句 2.1.DELETE 2.2.TRUNCATE 3.更新语句 3.1.UPDATE 3.2.带子查询的 UPDATE 3 ...

  4. LoadRunner 调用Dll完成加密解密

    LoadRunner里的函数比较少,没有MD5.Base64加密. 我们可以通过在C++里把一些加解密写成函数,供LR调用. DLL函数编写 C++里新建工程Class Library(此处是用VS2 ...

  5. 2.JAVA垃圾回收机制

    前言 线程独享的内存区域有程序计数器,虚拟机栈,本地方法栈,这些区域不用考虑内存回收的问题,随着线程的执行结束,自然就回收了,而堆内存和方法区的回收则不一样,他们的内存分配和回收是动态的. 1.对象存 ...

  6. 三层——c#版

    首先,向大家通知一个好消息--我的三层终于实现了!!!这两天,一直在调一个bug一直链接不上数据库,弄得我死的心都有了.就在昨天,当我把一个","改成了":"后 ...

  7. python - bilibili(三)wireshark分析

    当我们开始打开浏览器,并进入B站直播网页前,我们打开wireshark软件(软件的下载与安装请百度一下)开始截取当前数据. 然后输入直播间网址,enter进入就可以停止截取数据了,然后我们分析所截取的 ...

  8. scala IDE错误:..is cross-compiled with incompatible version....

    下午scala工程出现如下错误: 搜索这个问题,没有找到答案. 直接去官网查看http://scala-ide.org/docs/current-user-doc/faq/index.html,发现了 ...

  9. JavaScript中国象棋程序(5) - Alpha-Beta搜索

    "JavaScript中国象棋程序" 这一系列教程将带你从头使用JavaScript编写一个中国象棋程序.这是教程的第5节. 这一系列共有9个部分: 0.JavaScript中国象 ...

  10. 学习git的使用--在当地的简单命令--01

    <----------git安装完成后操作-----------------> git config --global user.name "scy"添加用户名git ...