]> git.openstreetmap.org Git - nominatim.git/commit
improve deadlock detection for various versions of psycopg2
authorSarah Hoffmann <lonvia@denofr.de>
Thu, 25 Feb 2021 16:36:31 +0000 (17:36 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Thu, 25 Feb 2021 17:11:16 +0000 (18:11 +0100)
commita1f0fc1a10db6fe3b8c329b3899b211ea0b62079
tree438bf6586127eb86dcec44309888ba374e57695b
parent72b01148d2d12f71c12440c15fa078b55e1c8f86
improve deadlock detection for various versions of psycopg2

Psycopg2 has changed the kind of exception that is emitted on
deadlocks between versions 2.7 and 2.8. The code was already
trying to catch both kind of errors but because the
psycopg2.errors package is unknown in 2.7 and below, the
code would throw an exception on anything but a deadlock error.

This commit wraps the deadlock handling into a context manager
to avoid code duplication and uses module imports to detect if
the new error codes are available.

Also sets the required psycopg2 version to 2.7 or bigger as
versions below are difficult to test.
docs/admin/Installation.md
nominatim/db/async_connection.py
test/python/test_db_async_connection.py [new file with mode: 0644]