Skip to content

Commit

Permalink
Rename AsyncPooledPostgresqlConnection -> AsyncPostgresqlConnectionPo…
Browse files Browse the repository at this point in the history
…ol; move default timeyout setting to AsyncPostgresqlConnectionPool.__init__()
  • Loading branch information
rudyryk committed Apr 18, 2016
1 parent 7bb1945 commit 597b930
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions peewee_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,14 +732,14 @@ def fetchone(self):
##############


class AsyncPooledPostgresqlConnection:
"""Asynchronous database connection pool wrapper.
class AsyncPostgresqlConnectionPool:
"""Asynchronous database connection pool.
"""
def __init__(self, *, database=None, loop=None, timeout=None, **kwargs):
self.pool = None
self.loop = loop
self.database = database
self.timeout = timeout
self.timeout = timeout or aiopg.DEFAULT_TIMEOUT
self.connect_kwargs = kwargs

@asyncio.coroutine
Expand Down Expand Up @@ -796,8 +796,8 @@ def close(self):
yield from self.pool.wait_closed()


class AsyncPostgresqlConnection(AsyncPooledPostgresqlConnection):
"""Asynchronous single database connection wrapper.
class AsyncPostgresqlConnection(AsyncPostgresqlConnectionPool):
"""Asynchronous single database connection.
"""
def __init__(self, *, database=None, loop=None, timeout=None, **kwargs):
kwargs['minsize'] = 1
Expand Down Expand Up @@ -852,7 +852,7 @@ def connect_async(self, loop=None, timeout=None):
conn = self._async_conn_cls(
database=self.database,
loop=self.loop,
timeout=(timeout or aiopg.DEFAULT_TIMEOUT),
timeout=timeout,
**self.connect_kwargs_async)

yield from conn.connect()
Expand Down Expand Up @@ -998,7 +998,7 @@ class PooledPostgresqlDatabase(AsyncPostgresqlMixin, peewee.PostgresqlDatabase):
"""
def init(self, database, **kwargs):
super().init(database, **kwargs)
self.init_async(conn_cls=AsyncPooledPostgresqlConnection)
self.init_async(conn_cls=AsyncPostgresqlConnectionPool)
self.min_connections = self.connect_kwargs.pop('min_connections', 1)
self.max_connections = self.connect_kwargs.pop('max_connections', 20)

Expand Down

0 comments on commit 597b930

Please sign in to comment.