Having the client provide general handling for in-flight timeouts would be the overall best solution imho.
psycopg by date:
Соглашаюсь с условиями обработки персональных данных