このテストでは、 "RuntimeError:Pythonオブジェクトを呼び出す際に最大再帰深度を超えました"というエラーメッセージが表示されます。 300番目のテストでは、 "sys.setrecursionlimit(10000)"を試してみましたが、問題を修正しましたが、これがこのエラーについての最良の方法ではないことを知っています。エラー:runtimeerror:最大再帰の深さがPythonを超えました
def SndRcv(self,request):
print ">> ", request
device_api.send(request)
resp = device_api.receive()
print "<< ", resp
self.processResponse(resp)
def processResponse(self, K400Message):
global mWaitingCardRemoval
ciMsg = card_interface_response
ciMsgType = card_interface_response.ci_msg
if ciMsgType is None:
print 'weird, malformed protobuf response'
return
whichMsg = ciMsgType.WhichOneof('msg')
print 'msg = ' + str(whichMsg)
if whichMsg is 'collision':
self.StartSession()
elif whichMsg is 'card_removed':
if ciMsgType.issuer== ci.CARD_INTERFACE_MASK_CxLESS:
mWaitingCardRemoval &= ~(ciMsgType.issuer)
if EndofSession is False:
self.parseMessage()
if mWaitingCardRemoval !=0:
self.parseMessage()
self.StartSession()
elif whichMsg is 'waiting_removal':
if EndofSession is False:
self.parseMessage()
else:
mWaitingCardRemoval |= ciMsgType.issuer
elif whichMsg is 'card_detected':
mode = ciMsgType.issuer
reqMsg = pm.get_Deactivate((ci.CARD_INTERFACE_MASK_ANY)& ~(ciMsgType.issuer))
self.SendOnly(reqMsg)
acceptMsg = pm.get_Activate(mode)
self.SndRcv(acceptMsg)
elif whichMsg is 'card_ready':
self.StartLoop(ciMsgType.issuer)
elif whichMsg is 'rapdu':
self.processCardAPDUResponse(ciMsgType.issuer, ciMsg.data.encode('hex'))
elif whichMsg is 'card_not_responding':
if ciMsgType.issuer == ci.CARD_INTERFACE_MASK_CONTACT:
self.EndCardSession(ciMsgType.issuer,True)
else:
self.EndCardSession(ciMsgType.issuer, False)
elif whichMsg is 'resp_special':
if ciMsg.data.encode('hex') > 0:
logging.info(ciMsg.data.encode('hex'))
else:
logging.info("")
'self.SndRcv'は' self.processResponse'を呼び出し、 'self.processResponse'は' self.SndRcv'を呼び出します。なぜそれが任意の深度再帰につながるのか分かりますか? –
再帰を理解するには、再帰を理解する必要があります。 – moooeeeep
ビットを拡張する: '' 'SndRcv'''は返されず、' 'processResponse'''はciMsgTypeがNone''''の場合のみ' ''を返します。 – wwii