python - PyPy + Storm ORM 不工作(cpyext 问题)

标签 python pypy storm-orm

作为最近启动的项目的一部分,以下是我们正在使用的虚拟环境的配置:

PyPy 2.2.1
Mysql-python 1.2.5
Storm orm 0.20

PyPy 和 Storm 基本上是我们被告知不要更改的一些要求。但是,在一个非常小的测试中,我们在 Storm ORM 方面遇到了问题。因此,在我们的代码中尝试一些非常简单的事情:

...
users = store.find(User)
for u in users:
    print u.fullname
...

在控制台中产生以下错误:

...
Fatal error in cpyext, CPython compatibility layer, calling PyTuple_New
Either report a bug or consider not using this particular extension
<StackOverflow object at 0x1c7c1a8>
RPython traceback:
  File "pypy_module_cpyext_api.c", line 35143, in PyTuple_New
  File "pypy_module_cpyext_pyobject.c", line 547, in make_ref
  File "pypy_module_cpyext_pyobject.c", line 1387, in create_ref
  File "rpython_rlib_rstack.c", line 65, in stack_check_slowpath

我们认为连接器是问题所在,因此尝试使用 PyMySQL(它是 MySQLdb 的直接替代品),但遇到了同样的问题。 然后,我们安装了 SQLAlchemy 并且它运行完美,所以看起来问题出在 Storm 上。

那么,有人知道如何让 Storm ORM 在 PyPy 环境中工作吗?

最佳答案

好吧,经过更多调查,似乎有一种方法可以在 PyPy 上使用 Storm。取自https://github.com/DamnWidget/mamba/blob/master/mamba/init.py基本上,将其添加到我的代码中就可以解决问题:

import sys
if '__pypy__' in sys.modules:
    # we are running on PyPy interpreter make sure we don't use the
    # Storm C extensions that make PyPy cpyext crash
    import os
    os.environ.update({'STORM_CEXTENSIONS': '0'})

这样,我在进行的其他测试中就不再遇到任何问题了。

希望这对有同样情况的人有所帮助。

关于python - PyPy + Storm ORM 不工作(cpyext 问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22738768/

相关文章:

python - undefined symbol : xmlMemDisplayLast error with lxml

python - PyPy 中是否有替代 sys.getsizeof() 的方法?

python - 最近对 Python 执行模型的更改?

pypy - Mac OS X 10.9.5 + pypy 2.6 上出现 "No module named _vmprof"错误

python - 修改单个 BigQuery 列并写入新表

python - 如何让Django管理命令不开启事务?

Python Excel 图表类型 pywintypes.com_error

python - 如何创建没有主键的Storm表?

python - Storm 或 SQLAlchemy ORM 是否允许从现有数据库创建模式?