1

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

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 环境中工作?

4

1 回答 1

2

Ok, after more investigation, it seems like there is a way to use Storm on PyPy. Taken from https://github.com/DamnWidget/mamba/blob/master/mamba/init.py, basically, adding this to my code did the trick:

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'})

this way, I haven't experienced any more issues on the other tests I did.

Hope this helps anyone with the same situation.

于 2014-03-30T02:16:05.750 回答