作为最近启动的项目的一部分,以下是我们正在使用的虚拟环境的配置:
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/