gpt4 book ai didi

Redis 数据库在完成几乎所有任务后给出 "Connection refused"错误

转载 作者:可可西里 更新时间:2023-11-01 11:00:46 25 4
gpt4 key购买 nike

我正在尝试解析存储在 redis 数据库中的一些数据(在我的本地机器上,通过默认端口 6739 访问)。本质上,任务是迭代数据库中大约 10K 的哈希结构,从当前哈希中的字段计算出一个新字段,然后将该新字段写回数据库,这样我就不需要再次进行计算。

我的脚本启动正常,连接到数据库,并在崩溃之前通过大约 9500 个哈希值,并出现“redis.exceptions.ConnectionError:错误 111 连接本地主机:6379。连接被拒绝。”错误。我已经重新启动了运行它多次的 EC2 实例,每次它都在同一个地方崩溃。

知道会发生什么吗?为什么 Redis 可以处理一些数据集然后崩溃?

编辑:这是执行的输出。它在死前运行了大约 3 分半钟。

$ sudo python parser.py 
Added 0 out of 10378 to dictionary: 22:48:53
Added 100 out of 10378 to dictionary: 22:48:54
Added 200 out of 10378 to dictionary: 22:48:55
Added 300 out of 10378 to dictionary: 22:48:57
Added 400 out of 10378 to dictionary: 22:48:58
Added 500 out of 10378 to dictionary: 22:49:00
...
Added 9000 out of 10378 to dictionary: 22:51:16
Added 9100 out of 10378 to dictionary: 22:51:30
Added 9200 out of 10378 to dictionary: 22:51:44
Added 9300 out of 10378 to dictionary: 22:52:00
Added 9400 out of 10378 to dictionary: 22:52:15
Added 9500 out of 10378 to dictionary: 22:52:17
Traceback (most recent call last):
File "parser.py", line 180, in <module>
buildDictionary(force=True)
File "parser.py", line 123, in buildDictionary
addPostToDict(postid)
File "parser.py", line 92, in addPostToDict
comments = [contentFromId(commentid) for commentid in commentids]
File "parser.py", line 72, in contentFromId
content = db.hget(contentid, keyword)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 1539, in hget
return self.execute_command('HGET', name, key)
File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 464, in execute_command
connection.send_command(*args)
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 334, in send_command
self.send_packed_command(self.pack_command(*args))
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 316, in send_packed_command
self.connect()
File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 253, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 111 connecting localhost:6379. Connection refused.

最佳答案

您可以在 Redis 中设置超时和内存限制,以确保它能够处理长连接和超时

关于Redis 数据库在完成几乎所有任务后给出 "Connection refused"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23598728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com