Skip to content

Reopen postgresql db connection to be more robust #12

Description

@bernhardreiter

ffb268e v0.5.1 will fail if a database connection is closed.
Apache's mod_wsgi may restart the processes onces in the while, so there is some self healing.

Simple test to reproduce:
systemctl restart postgresql.service in a running contactdb_api results into

cur = contactdb_conn.cursor(cursor_factory=RealDictCursor)
psycopg2.InterfaceError: connection already closed

Technical idea:

Use psycopg2.pool.ThreadedConnectionPool().

This might also help to speed up access and use multiple threads with wsgi,
which would need an update in the Apache config instructions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions