@@ -49,6 +49,7 @@ def __init__(
4949 pool_factory : Callable [
5050 ..., psycopg_pool .AsyncConnectionPool
5151 ] = psycopg_pool .AsyncConnectionPool ,
52+ pool_kwargs : dict [str , Any ] | None = None ,
5253 ** kwargs : Any ,
5354 ):
5455 """
@@ -93,6 +94,7 @@ def __init__(
9394 self ._json_loads = json_loads
9495 self ._json_dumps = json_dumps
9596 self ._pool_args = kwargs
97+ self ._pool_kwargs = pool_kwargs
9698 self ._sync_connector : connector .BaseConnector | None = None
9799
98100 def get_sync_connector (self ) -> connector .BaseConnector :
@@ -140,24 +142,27 @@ async def open_async(
140142 self ._pool_externally_set = True
141143 self ._async_pool = pool
142144 else :
143- self ._async_pool = await self ._create_pool (self ._pool_args )
145+ self ._async_pool = await self ._create_pool (
146+ self ._pool_args , self ._pool_kwargs
147+ )
144148
145149 await self ._async_pool .open (wait = True ) # type: ignore
146150
147151 @wrap_exceptions ()
148152 async def _create_pool (
149- self ,
150- pool_args : dict [str , Any ],
153+ self , pool_args : dict [str , Any ], pool_kwargs : dict [str , Any ] | None
151154 ) -> psycopg_pool .AsyncConnectionPool :
155+ pool_kwargs = pool_kwargs if pool_kwargs is not None else {}
152156 return self ._pool_factory (
153- ** pool_args ,
157+ kwargs = pool_args . get ( "kwargs" , {}) ,
154158 # Not specifying open=False raises a warning and will be deprecated.
155159 # It makes sense, as we can't really make async I/Os in a constructor.
156160 open = False ,
157161 # Enables a check that will ensure the connections returned when
158162 # using the pool are still alive. If they have been closed by the
159163 # database, they will be seamlessly replaced by a new connection.
160164 check = psycopg_pool .AsyncConnectionPool .check_connection ,
165+ ** pool_kwargs ,
161166 )
162167
163168 @wrap_exceptions ()
0 commit comments