python - 应用引擎 : IOError when saving a lot of objects to the Datastore

标签 python google-app-engine ubuntu binary-tree

大家干杯。我正在运行 Ubuntu 10.04 和最新的 Google AppEngine SDK。我正在开发一个简单的网站,其中包含帖子和帖子评论。我基本上实现了一个简单的树来存储我的评论 parent_comment , leftright值。

我创建了一个在新 ( not is_saved() ) 评论之前触发的事件 put()进入 Google 数据存储区,计算 leftright新注释的值,以及更新有效层次结构的旧注释。我基本上就跟着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/

相关文章:

python - 如何在 Linux 上安装 Python 包,以便可以通过已经运行的 PostgreSQL 13 plpython3u 扩展找到它?

python - 为什么我的程序可以连接到一个不存在的网站?

python - 日期时间范围中前一天/前一个月/前一年的第一个可用日期

python - Tensorflow:自定义 softmax 的 NaN

google-app-engine - 如何从 GQL 中的键值检索实体

python - 谷歌应用引擎单元测试 : Difficulty with AssertEquals

google-app-engine - 如何在 App Engine 上实现服务器亲和性或粘性 session ?

mysql - 在ubuntu上安装mysql后访问被拒绝

ubuntu - ubuntu中超过3个DNS服务器

python - 如何使用 Python 向 Bluemix CF API 进行身份验证