Skip to content

AttributeError: 'function' object has no attribute '_yield_per' when upgrading to SQLAlchemy 1.4 #281

Closed
@mvanbaak

Description

@mvanbaak
Traceback (most recent call last):
  File "/Users/mvanbaak/dev/frontrow/public-api/src/fr_public_api/helpers/brandresolver.py", line 36, in resolve_brand_for_apikey
    key = db.session.query(ApiKey).filter_by(key=api_key).one()
  File "/Users/mvanbaak/.dotfiles/virtualenvs/fr_public_api/lib/python3.7/site-packages/aws_xray_sdk/ext/sqlalchemy/util/decorators.py", line 63, in wrapper
    res = func(*args, **kw)
  File "/Users/mvanbaak/.dotfiles/virtualenvs/fr_public_api/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2730, in one
    return self._iter().one()
  File "/Users/mvanbaak/.dotfiles/virtualenvs/fr_public_api/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 2771, in _iter
    execution_options={"_sa_orm_load_options": self.load_options},
  File "/Users/mvanbaak/.dotfiles/virtualenvs/fr_public_api/lib/python3.7/site-packages/aws_xray_sdk/ext/sqlalchemy/util/decorators.py", line 63, in wrapper
    res = func(*args, **kw)
  File "/Users/mvanbaak/.dotfiles/virtualenvs/fr_public_api/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1616, in execute
    _parent_execute_state is not None,
  File "/Users/mvanbaak/.dotfiles/virtualenvs/fr_public_api/lib/python3.7/site-packages/sqlalchemy/orm/context.py", line 253, in orm_pre_session_exec
    if "yield_per" in execution_options or load_options._yield_per:
AttributeError: 'function' object has no attribute '_yield_per'

Versions:

Flask==1.1.2
SQLAlchemy==1.4.2
Flask-SQLAlchemy==2.5.1

boto3==1.17.35
botocore==1.20.36
aws-xray-sdk==2.7.0

I get the same error with SQLAlchemy 1.4.0 and 1.4.1, things work fine with 1.3.23.

Confirmed it's an xray issue with the following change to my code which made things work again:

-db = XRayFlaskSqlAlchemy(model_class=Base)
+db = SQLAlchemy(model_class=Base)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions