From: Daniele Varrazzo Date: Wed, 13 Dec 2023 11:31:13 +0000 (+0100) Subject: fix: honour the PGLOADBALANCEHOSTS env var X-Git-Tag: 3.1.15~1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=556033323c4fe796c14268c7d1b3c0def0dec90c;p=thirdparty%2Fpsycopg.git fix: honour the PGLOADBALANCEHOSTS env var --- diff --git a/psycopg/psycopg/conninfo.py b/psycopg/psycopg/conninfo.py index 9d276ebc0..3cc8bbb3e 100644 --- a/psycopg/psycopg/conninfo.py +++ b/psycopg/psycopg/conninfo.py @@ -304,7 +304,7 @@ def conninfo_attempts(params: ConnDict) -> list[ConnDict]: # one attempt and wouldn't get to try the following ones, as before # fixing #674. attempts = _split_attempts(params) - if params.get("load_balance_hosts", "disable") == "random": + if _get_param(params, "load_balance_hosts") == "random": shuffle(attempts) return attempts @@ -337,7 +337,7 @@ async def conninfo_attempts_async(params: ConnDict) -> list[ConnDict]: # We couldn't resolve anything raise e.OperationalError(str(last_exc)) - if params.get("load_balance_hosts", "disable") == "random": + if _get_param(params, "load_balance_hosts") == "random": shuffle(attempts) return attempts