St.connection errors

Hi All,
I have an app interacting with remote Postgresql database. From time to time I might receive the following error message: sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
Typically the problem will be resolved if I rerun the page.
The server is on and I never have problems when connecting it with other database managers.

I am wondering if this is due the fact that I didn’t close my session. In my code, I am using:

        conn = st.connection("postgresql", type="sql")
        session = conn.session
        result = session.execute(text(query))
        data = result.fetchall()

I didn’t call session.close() and conn.close() in the end because Streamlit is managing the connections. Should I call both methods?

Thank you very much for your help.