我正在尝试删除 Redis 中除某些键之外的所有键,但确实出现以下异常:
... File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/basic.py", line 572, in dataReceived
return self.rawDataReceived(data)
File "build/bdist.macosx-10.6-intel/egg/txredisapi/protocol.py", line 184, in rawDataReceived
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/basic.py", line 589, in setLineMode
return self.dataReceived(extra)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/twisted/protocols/basic.py", line 564, in dataReceived
why = self.lineReceived(line)
File "build/bdist.macosx-10.6-intel/egg/txredisapi/protocol.py", line 134, in lineReceived
exceptions.RuntimeError: maximum recursion depth exceeded
这是代码:
@defer.inlineCallbacks
def resetAll(self):
dict=yield self.factory.conn.keys()
for xyz in dict:
if xyz<>"game" and xyz<>"people" and xyz<>"said":
val = yield self.factory.conn.delete(xyz)
# ...
if __name__ == '__main__':
from twisted.internet import reactor
conn = txredisapi.lazyRedisConnectionPool(reconnect = True)
factory = STSFactory(conn)
factory.clients = []
print "Server started"
reactor.listenTCP(11000,factory)
reactor.listenTCP(11001,factory)
reactor.listenTCP(11002,factory)
reactor.run()
当我在 Redis 中使用大约 725 个键调用 resetAll 函数时,我触发了异常。对于较低的数字,如 200 等,它不会被解雇。有人知道发生了什么吗?谢谢。