Skip to content

Commit f280a56

Browse files
committed
Refactor args parsing and config management for connect and create_pool
Added: * `connection_class` parameter to connect() and create_pool() to specify a custom Connection object. * `server_settings` parameter to connect() and create_pool() to set custom server connection settings. Fixed: * Connection pool to always create Connections with correct configuration. Before, the pool could lose parameters like `statement_cache_size`. Backwards Compatibility: * connect() and create_pool() no longer accept arbitrary keyword arguments for server settings. Use new `server_settings` argument for that.
1 parent 3354d87 commit f280a56

11 files changed

+555
-384
lines changed

asyncpg/__init__.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
# the Apache 2.0 License: http://www.apache.org/licenses/LICENSE-2.0
66

77

8-
from .connection import connect # NOQA
8+
from .connection import connect, Connection # NOQA
99
from .exceptions import * # NOQA
1010
from .pool import create_pool # NOQA
1111
from .protocol import Record # NOQA
1212
from .types import * # NOQA
1313

1414

15-
__all__ = ('connect', 'create_pool', 'Record') + exceptions.__all__ # NOQA
15+
__all__ = ('connect', 'create_pool', 'Record', 'Connection') + \
16+
exceptions.__all__ # NOQA

asyncpg/_testbase.py

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919

2020
from asyncpg import cluster as pg_cluster
21+
from asyncpg import connection as pg_connection
2122
from asyncpg import pool as pg_pool
2223

2324

@@ -162,12 +163,14 @@ def create_pool(dsn=None, *,
162163
init=None,
163164
loop=None,
164165
pool_class=pg_pool.Pool,
166+
connection_class=pg_connection.Connection,
165167
**connect_kwargs):
166168
return pool_class(
167169
dsn,
168170
min_size=min_size, max_size=max_size,
169171
max_queries=max_queries, loop=loop, setup=setup, init=init,
170172
max_inactive_connection_lifetime=max_inactive_connection_lifetime,
173+
connection_class=connection_class,
171174
**connect_kwargs)
172175

173176

0 commit comments

Comments
 (0)