Sunday, 25 November 2018

SqlAlchemy logging "SystemError: error return without exception set"

I'm currently developing a web-app which uses a combination of SqlAlchemy Flask and Marshmallow to serialise Sqlite data into JSON for the front-end. I've used this setup in multiple occasions which worked fine, however this time my console is continuously spammed with the following errors:

    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

This causes my application to slow down due to the fact that it needs to process so much text in the window, and requests can sometimes take up to five seconds to complete. After looking online I've found out this might be caused by some library written in CPython that returns an incorrect exception object: source

If one of the two actions is missing then the exception will not be raised correctly. For example returning NULL without setting an exception type:

/* Illustrate returning NULL but not setting an exception. */
static PyObject *_raise_error_bad(PyObject *module) {
    return NULL;
}

Executing this from Python will produce a clear error message (the C function _raise_error_bad() is mapped to the Python function cExcep.raiseErrBad()

>>> cExcep.raiseErrBad()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SystemError: error return without exception set

Example code which triggers the error (completely valid and works most of the time):

MyTable.query.filter_by(guid=room["guid"]).first()

Does anyone know what might be causing this? Looking at the stack traces it's something to do with SqlAlchemy and Generators but I can't seem to figure out why it's doing this. Thanks

  • Python version: 3.6.3
  • Flask version: 0.12.2
  • Flask SqlAlchemy version: 2.3.2


from SqlAlchemy logging "SystemError: error return without exception set"

No comments:

Post a Comment