- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我正在尝试删除 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 等较低的数字,它不会被解雇。任何人都知道发生了什么事?谢谢。
最佳答案
在具有 root 访问权限并安装了 Python 和 Git 的 Linux/Mac 计算机的终端上尝试此操作:
cd
git clone https://github.com/andymccurdy/redis-py.git redis-py
cd redis-py
sudo python setup.py install
Behind the scenes, redis-py uses a connection pool to manage connections to a Redis server. By default, each Redis instance you create will in turn create its own connection pool. You can override this behavior and use an existing connection pool by passing an already created connection pool instance to the connection_pool argument of the Redis class.
#!/usr/bin/python
import redis
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
r = redis.Redis(connection_pool=pool)
keys = r.keys()
for key in keys:
if key<>"game" and key<>"people" and key<>"said":
r.del(key)
请注意我尚未测试过,但您的评论可能会影响最终解决方案,或者您可以从这里开始。始终在 redis-cli 中进行监控以确保安全。
关于python - Txredisapi异常.RuntimeError : maximum recursion depth exceeded,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9100208/
我在一个使用 Python、Twisted 和 Redis 的项目中工作。因此,团队决定使用 txredisapi 进行 Python 模块和 Redis 之间的通信。这个项目做了很多不同的事情,我们
使用 Python、Twisted、Redis 和 txredisapi。 如何在建立连接后获取用于订阅和取消订阅 channel 的 SubscriberProtocol? 我想我需要获取 Subs
下面我提供了一个代码示例,它使用来自 Redis 的数据简单地响应 HTTP GET 请求: 请求: http://example.com:8888/?auth=zefDWDd5mS7mcbfoDbD
我是一名优秀的程序员,十分优秀!