Skip to content

Commit 61cf256

Browse files
wwwjfyfantix
authored andcommitted
fix python-gino/gino#407, extensions accept kwargs for db init
1 parent 1f60bcc commit 61cf256

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

gino/ext/quart.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ async def before_first_request():
116116
max_size=app.config.setdefault('DB_POOL_MAX_SIZE', 10),
117117
ssl=app.config.setdefault('DB_SSL'),
118118
loop=asyncio.get_event_loop(),
119+
**app.config.setdefault('DB_KWARGS', dict()),
119120
)
120121

121122
async def first_or_404(self, *args, **kwargs):

tests/test_quart.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@
1818
from .models import DB_ARGS, PG_URL
1919

2020
pytestmark = pytest.mark.asyncio
21+
_MAX_INACTIVE_CONNECTION_LIFETIME = 59.0
2122

2223

2324
# noinspection PyShadowingNames
2425
async def _app(config):
2526
app = Quart(__name__)
2627
app.config.update(config)
28+
app.config.update({
29+
'DB_KWARGS': dict(
30+
max_inactive_connection_lifetime=_MAX_INACTIVE_CONNECTION_LIFETIME,
31+
),
32+
})
2733

2834
db = Gino(app)
2935

@@ -35,6 +41,10 @@ class User(db.Model):
3541

3642
@app.route('/')
3743
async def root():
44+
conn = await request.connection.get_raw_connection()
45+
# noinspection PyProtectedMember
46+
assert conn._holder._max_inactive_time == \
47+
_MAX_INACTIVE_CONNECTION_LIFETIME
3848
return 'Hello, world!'
3949

4050
async def _get_user(ctx, uid: int, method: str) -> dict:

0 commit comments

Comments
 (0)