Closed aoghina closed 7 years ago
A workaround is to do this:
db = SQLAlchemy()
def __bogus_flush():
raise AssertionError
db.session.flush = __bogus_flush
init_social(app, db.session)
It works because if flush() raises and AssertionError
, then python-social-auth does commit.
Actually this seems to be the offending commit: https://github.com/omab/python-social-auth/commit/a52ee69cc641018bbf32c6fd599a6c30036b3086
Probably since this commit, python-social-auth no longer works with flask_sqlalchemy:
https://github.com/omab/python-social-auth/commit/cc5908675c95944b68aae038700c7ee901aff491#diff-a622acca45e0e3a8d67139fe21cd35fe
If we pass the
db.session
(where db is the SQLAlchemy object) instead ofdb_session
toinit_social(app, db_session)
, which is a scoped session, things seem to work fine until python-social-auth has to add a new user, when it timeouts withLock wait timeout exceeded; try restarting transaction
on theINSERT INTO social_auth_usersocialauth
statement.It has something to do with the sequence of flushing and committing, because if we do
cls._session().commit()
instead ofcls._flush()
inSQLAlchemyMixin._save_instance
, then it works fine.