Skip to content Skip to sidebar Skip to footer

Sqlalchemy Long Running Script: User Was Holding A Relation Lock For Too Long

I have an SQLAlchemy session in a script. The script is running for a long time, and it only fetches data from database, never updates or inserts. I get quite a lot of errors like

Solution 1:

I ended up closing the session after (almost) every select, like

session.query(Foo).all()
session.close()

since I do not use autocommit, a new transaction is automatically opened.

Post a Comment for "Sqlalchemy Long Running Script: User Was Holding A Relation Lock For Too Long"