@@ -230,15 +230,13 @@ def _use_multiplexed(cls, transaction_type: TransactionType) -> bool:
230230 """Returns whether to use multiplexed sessions for the given transaction type.
231231
232232 Multiplexed sessions are enabled for read-only transactions if:
233- * _ENV_VAR_MULTIPLEXED is set to true .
233+ * _ENV_VAR_MULTIPLEXED != 'false' .
234234
235235 Multiplexed sessions are enabled for partitioned transactions if:
236- * _ENV_VAR_MULTIPLEXED is set to true; and
237- * _ENV_VAR_MULTIPLEXED_PARTITIONED is set to true.
236+ * _ENV_VAR_MULTIPLEXED_PARTITIONED != 'false'.
238237
239238 Multiplexed sessions are enabled for read/write transactions if:
240- * _ENV_VAR_MULTIPLEXED is set to true; and
241- * _ENV_VAR_MULTIPLEXED_READ_WRITE is set to true.
239+ * _ENV_VAR_MULTIPLEXED_READ_WRITE != 'false'.
242240
243241 :type transaction_type: :class:`TransactionType`
244242 :param transaction_type: the type of transaction
@@ -254,30 +252,26 @@ def _use_multiplexed(cls, transaction_type: TransactionType) -> bool:
254252 return cls ._getenv (cls ._ENV_VAR_MULTIPLEXED )
255253
256254 elif transaction_type is TransactionType .PARTITIONED :
257- return cls ._getenv (cls ._ENV_VAR_MULTIPLEXED ) and cls ._getenv (
258- cls ._ENV_VAR_MULTIPLEXED_PARTITIONED
259- )
255+ return cls ._getenv (cls ._ENV_VAR_MULTIPLEXED_PARTITIONED )
260256
261257 elif transaction_type is TransactionType .READ_WRITE :
262- return cls ._getenv (cls ._ENV_VAR_MULTIPLEXED ) and cls ._getenv (
263- cls ._ENV_VAR_MULTIPLEXED_READ_WRITE
264- )
258+ return cls ._getenv (cls ._ENV_VAR_MULTIPLEXED_READ_WRITE )
265259
266260 raise ValueError (f"Transaction type { transaction_type } is not supported." )
267261
268262 @classmethod
269263 def _getenv (cls , env_var_name : str ) -> bool :
270264 """Returns the value of the given environment variable as a boolean.
271265
272- True values are '1' and 'true ' (case-insensitive).
273- All other values are considered false .
266+ True unless explicitly 'false ' (case-insensitive).
267+ All other values (including unset) are considered true .
274268
275269 :type env_var_name: str
276270 :param env_var_name: the name of the boolean environment variable
277271
278272 :rtype: bool
279- :returns: True if the environment variable is set to a true value , False otherwise.
273+ :returns: True unless the environment variable is set to 'false' , False otherwise.
280274 """
281275
282- env_var_value = getenv (env_var_name , "" ).lower ().strip ()
283- return env_var_value in [ "1" , "true" ]
276+ env_var_value = getenv (env_var_name , "true " ).lower ().strip ()
277+ return env_var_value != "false"
0 commit comments