Linked Questions

Popular Questions

I am using this docker container to run my flask web app, FROM python:3.8.16. In my flask app, I have a code in a @after_request function where I rollback my sqlite session whenever any rest API returns a 500 response code.The frontend sometimes requests more than one rest API parallelly and if they both send a 500 response , the container simple crashes because I am issuing multiple rollbacks. how to avoid this container crash.

Session is created using sessionmaker of sqlite3

from sqlalchemy.orm import sessionmaker
session = sessionmaker(self.db)

After request containing session rollbacks

def end_request(response):
    if response.status_code not in [200,201,202]:

Related Questions