我目前正在开发一个Web应用程序,该应用程序使用SqlAlchemy Flask和Marshmallow的组合将SQLite数据序列化为前端的JSON。我已经在多个场合使用过这种设置,但是,这次我的控制台不断被垃圾邮件发送,并出现以下错误:
Exception ignored in: <generator object surface_selectables at 0x13b399888>
Traceback (most recent call last):
File "/Users/luke/Documents/Projects/project/venv/lib/python3.6/site-packages/sqlalchemy/sql/util.py", line 231, in surface_selectables
yield elem
SystemError: error return without exception set
Exception ignored in: <generator object _visitor_iterator at 0x13b399888>
Traceback (most recent call last):
File "/Users/luke/Documents/Projects/project/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 150, in _visitor_iterator
yield v
SystemError: error return without exception set
Exception ignored in: <generator object _visitor_iterator at 0x13b399888>
Traceback (most recent call last):
File "/Users/luke/Documents/Projects/project/venv/lib/python3.6/site-packages/sqlalchemy/sql/visitors.py", line 150, in _visitor_iterator
yield v
SystemError: error return without exception set
这导致我的应用程序因为它需要在窗口中处理如此多的文本而放慢速度,并且请求有时可能需要五秒钟才能完成。在线查看之后我发现这可能是由CPython编写的一些库引起的,它返回了一个不正确的异常对象: source
如果缺少这两个操作中的一个,则不会发生异常 提出正确。例如,在不设置的情况下返回NULL 异常类型:
/* Illustrate returning NULL but not setting an exception. */ static PyObject *_raise_error_bad(PyObject *module) { return NULL; }
从Python执行此操作将产生明确的错误消息(C function _raise_error_bad()映射到Python函数 cExcep.raiseErrBad()
>>> cExcep.raiseErrBad() Traceback (most recent call last): File "<stdin>", line 1, in <module> SystemError: error return without exception set
触发错误的示例代码(完全有效且大部分时间都有效):
MyTable.query.filter_by(guid=room["guid"]).first()
有谁知道可能导致这种情况的原因?查看堆栈跟踪它与SqlAlchemy和Generators有关,但我似乎无法弄清楚它为什么这样做。感谢
编辑:以下是我上次参与项目时出现的错误pip freeze
的结果(导致出现错误):
alembic==0.9.8
APScheduler==3.5.3
asn1crypto==0.24.0
bleach==2.1.3
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
check-manifest==0.37
click==6.7
cmarkgfm==0.4.2
colorama==0.3.9
coverage==4.5.1
cryptography==2.3.1
docutils==0.14
Flask==0.12.2
flask-marshmallow==0.8.0
Flask-Migrate==2.1.1
Flask-SocketIO==2.9.2
Flask-SQLAlchemy==2.3.2
Flask-Testing==0.7.1
future==0.16.0
gevent-websocket==0.10.1
gitflow.releaser==2.0.4
greenlet==0.4.13
html5lib==1.0.1
idna==2.6
itsdangerous==0.24
Jinja2==2.10
Mako==1.0.7
MarkupSafe==1.0
marshmallow==2.14.0
marshmallow-enum==1.4.1
marshmallow-sqlalchemy==0.13.2
mysql-connector-python==8.0.6
pkginfo==1.4.2
pycparser==2.18
Pygments==2.2.0
PyMySQL==0.9.2
pyroma==2.3.1
python-dateutil==2.7.0
python-editor==1.0.3
python-engineio==2.0.3
python-socketio==1.9.0
pytz==2018.5
readme-renderer==20.0
requests==2.18.4
requests-toolbelt==0.8.0
six==1.11.0
SQLAlchemy==1.2.5
stringcase==1.2.0
tqdm==4.23.4
twine==1.11.0
tzlocal==1.5.1
urllib3==1.22
webencodings==0.5.1
Werkzeug==0.14.1
zest.releaser==6.15.0