@@ -156,11 +156,20 @@ def _create_pool(self) -> AbstractSessionPool:
156156 database = instance .database (database_id , pool = None )
157157
158158 pool_type = cast ("type[AbstractSessionPool]" , self .pool_config .get ("pool_type" , FixedSizePool ))
159- connection_keys = {"project" , "instance_id" , "database_id" , "credentials" , "client_options" , "pool_type" }
160- pool_kwargs = {k : v for k , v in self .pool_config .items () if k not in connection_keys and v is not None }
161159
162- if pool_type is FixedSizePool and "size" not in pool_kwargs and "max_sessions" in self .pool_config :
163- pool_kwargs ["size" ] = self .pool_config ["max_sessions" ]
160+ pool_kwargs : dict [str , Any ] = {}
161+ if pool_type is FixedSizePool :
162+ if "size" in self .pool_config :
163+ pool_kwargs ["size" ] = self .pool_config ["size" ]
164+ elif "max_sessions" in self .pool_config :
165+ pool_kwargs ["size" ] = self .pool_config ["max_sessions" ]
166+ if "labels" in self .pool_config :
167+ pool_kwargs ["labels" ] = self .pool_config ["labels" ]
168+ else :
169+ valid_pool_keys = {"size" , "labels" , "ping_interval" }
170+ pool_kwargs = {k : v for k , v in self .pool_config .items () if k in valid_pool_keys and v is not None }
171+ if "size" not in pool_kwargs and "max_sessions" in self .pool_config :
172+ pool_kwargs ["size" ] = self .pool_config ["max_sessions" ]
164173
165174 pool_factory = cast ("Callable[..., AbstractSessionPool]" , pool_type )
166175 return pool_factory (database , ** pool_kwargs )
@@ -176,7 +185,7 @@ def provide_connection(
176185 """Yield a Snapshot (default) or Transaction from the configured pool."""
177186 database = self .get_database ()
178187 if transaction :
179- with cast ("Any" , database ).transaction () as txn : # type: ignore[no-untyped-call]
188+ with cast ("Any" , database ).transaction () as txn :
180189 yield cast ("SpannerConnection" , txn )
181190 else :
182191 with cast ("Any" , database ).snapshot () as snapshot :
0 commit comments