[GH-ISSUE #270] 'LocalStack' object has no attribute '__ident_func__' error on launch #82

Open
opened 2026-02-26 01:33:04 +03:00 by kerem · 2 comments
Owner

Originally created by @robintw on GitHub (Apr 27, 2022).
Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/270

After installing sandman2 in a clean environment, I ran it as follows:

sandman2ctl 'sqlite+pysqlite:///chinook.db'

(using the chinook sample database from here).

I get the following error:

Traceback (most recent call last):
  File "/Users/robin/mambaforge/envs/sandman/bin/sandman2ctl", line 5, in <module>
    from sandman2.__main__ import main
  File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/__init__.py", line 2, in <module>
    from sandman2.app import get_app, db, AutomapModel
  File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/app.py", line 18, in <module>
    from sandman2.service import Service
  File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/service.py", line 12, in <module>
    from sandman2.model import db
  File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/model.py", line 13, in <module>
    db = SQLAlchemy()
  File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 715, in __init__
    self.session = self.create_scoped_session(session_options)
  File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 748, in create_scoped_session
    scopefunc = options.pop('scopefunc', _app_ctx_stack.__ident_func__)
AttributeError: 'LocalStack' object has no attribute '__ident_func__'

After some Googling, I found that it might be a version issue with the latest version of werkzeug and the pinned version of flask-sqlalchemy (which was 2.4.0). Upgrading to the latest flask-sqlalchemy (2.5.1 currently) seems to fix it.

Shall I submit a PR to update setup.py to use the latest flask-sqlalchemy, or might be there be more to this that I'm missing?

Originally created by @robintw on GitHub (Apr 27, 2022). Original GitHub issue: https://github.com/jeffknupp/sandman2/issues/270 After installing sandman2 in a clean environment, I ran it as follows: ``` sandman2ctl 'sqlite+pysqlite:///chinook.db' ``` (using the chinook sample database from [here](https://www.sqlitetutorial.net/sqlite-sample-database/)). I get the following error: ``` Traceback (most recent call last): File "/Users/robin/mambaforge/envs/sandman/bin/sandman2ctl", line 5, in <module> from sandman2.__main__ import main File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/__init__.py", line 2, in <module> from sandman2.app import get_app, db, AutomapModel File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/app.py", line 18, in <module> from sandman2.service import Service File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/service.py", line 12, in <module> from sandman2.model import db File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/sandman2/model.py", line 13, in <module> db = SQLAlchemy() File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 715, in __init__ self.session = self.create_scoped_session(session_options) File "/Users/robin/mambaforge/envs/sandman/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 748, in create_scoped_session scopefunc = options.pop('scopefunc', _app_ctx_stack.__ident_func__) AttributeError: 'LocalStack' object has no attribute '__ident_func__' ``` After some Googling, I found that it might be a version issue with the latest version of werkzeug and the pinned version of flask-sqlalchemy (which was 2.4.0). Upgrading to the latest flask-sqlalchemy (2.5.1 currently) seems to fix it. Shall I submit a PR to update setup.py to use the latest flask-sqlalchemy, or might be there be more to this that I'm missing?
Author
Owner

@EloWork commented on GitHub (Jan 25, 2023):

Any updates here? I still see 2.4 in the code and I think I have the same issue. Only difference is for me it is a _FakeStack object missing that attribute.
AttributeError: '_FakeStack' object has no attribute '__ident_func__'

<!-- gh-comment-id:1403570877 --> @EloWork commented on GitHub (Jan 25, 2023): Any updates here? I still see 2.4 in the code and I think I have the same issue. Only difference is for me it is a _FakeStack object missing that attribute. `AttributeError: '_FakeStack' object has no attribute '__ident_func__'`
Author
Owner

@ArchiLantern commented on GitHub (Jun 6, 2023):

Any updates here? I still see 2.4 in the code and I think I have the same issue. Only difference is for me it is a _FakeStack object missing that attribute. AttributeError: '_FakeStack' object has no attribute '__ident_func__'

update Flask-SQLAlchemy works for me. ( the solution I looked at StackOverFlow)
pip install Flask-SQLAlchemy==2.5.1

<!-- gh-comment-id:1579532220 --> @ArchiLantern commented on GitHub (Jun 6, 2023): > Any updates here? I still see 2.4 in the code and I think I have the same issue. Only difference is for me it is a _FakeStack object missing that attribute. `AttributeError: '_FakeStack' object has no attribute '__ident_func__'` update Flask-SQLAlchemy works for me. ( the solution I looked at StackOverFlow) ` pip install Flask-SQLAlchemy==2.5.1`
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sandman2-jeffknupp#82
No description provided.