sandman2 icon indicating copy to clipboard operation
sandman2 copied to clipboard

'LocalStack' object has no attribute '__ident_func__' error on launch

Open robintw opened this issue 2 years ago • 2 comments

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?

robintw avatar Apr 27 '22 16:04 robintw

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__'

EloWork avatar Jan 25 '23 13:01 EloWork

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

ArchiLantern avatar Jun 06 '23 22:06 ArchiLantern