]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: honour the PGLOADBALANCEHOSTS env var
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Dec 2023 11:31:13 +0000 (12:31 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 13 Dec 2023 11:34:24 +0000 (12:34 +0100)
psycopg/psycopg/conninfo.py

index 9d276ebc0b0bd48f7fbb4254abcaa9e1895aa7f9..3cc8bbb3ed7515c61f4299ad1f1b280aa1e64d66 100644 (file)
@@ -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