大家干杯。我正在运行 Ubuntu 10.04 和最新的 Google AppEngine SDK。我正在开发一个简单的网站,其中包含帖子和帖子评论。我基本上实现了一个简单的树来存储我的评论 parent_comment
, left
和right
值。
我创建了一个在新 ( not is_saved()
) 评论之前触发的事件 put()
进入 Google 数据存储区,计算 left
和right
新注释的值,以及更新有效层次结构的旧注释。我基本上就跟着Managing Hierarchical Data in MySQL并用Python实现了它。
一切似乎都工作正常,添加了新评论,线程看起来不错,但是......
在启动期间提交 40 条评论的周期是有效的,但是当我将该周期增加到 80 或更多时,我会遇到 IOError:
IOError: [Errno 24] Too many open files: '/tmp/tmp0agXqU'
生成 60 条评论的代码如下所示:
for k in range(0, 4):
comments = {0: None}
for i in range(1, 21):
j = random.randrange(0, len(comments))
pc = comments[j]
comments[i] = Comment(
name=lipsum(count=1),
email=lipsum(count=1, make_slug=True) + '@email.com',
url='http://' + lipsum(count=2, make_slug=True) + '.com',
content=lipsum(count=random.randrange(10, 50)),
object_link=p.key(),
parent_comment=pc
)
comments[i].put()
lipsum
函数只是返回一段 lorem ipsum 文本。
关于如何解决这个问题有什么想法吗?谢谢!
最佳答案
对于大型任务队列工作人员,我也遇到了同样的问题。
切换到 SQLite您的本地数据存储可以解决该问题:
dev_appserver.py --use_sqlite
Since App Engine SDK 1.3.3, the Python SDK has a new experimental feature that gives the option to use SQLite as the datastore stub backend. Using SQLite within the dev_appserver should speed up performance of your local datastore when testing on large datasets.
有关 dev_appserver
文档,请查看 here
关于python - 应用引擎 : IOError when saving a lot of objects to the Datastore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4193610/