File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,7 @@ async def before_server_start(_, loop):
113113 max_size = app .config .setdefault ('DB_POOL_MAX_SIZE' , 10 ),
114114 ssl = app .config .setdefault ('DB_SSL' ),
115115 loop = loop ,
116+ ** app .config .setdefault ('DB_KWARGS' , dict ()),
116117 )
117118
118119 @app .listener ('after_server_stop' )
Original file line number Diff line number Diff line change 88
99from .models import DB_ARGS , PG_URL
1010
11+ _MAX_INACTIVE_CONNECTION_LIFETIME = 59.0
12+
1113
1214# noinspection PyShadowingNames
1315async def _app (config ):
1416 app = sanic .Sanic ()
1517 app .config .update (config )
18+ app .config .update ({
19+ 'DB_KWARGS' : dict (
20+ max_inactive_connection_lifetime = _MAX_INACTIVE_CONNECTION_LIFETIME ,
21+ ),
22+ })
1623
1724 db = Gino (app )
1825
@@ -24,6 +31,10 @@ class User(db.Model):
2431
2532 @app .route ('/' )
2633 async def root (request ):
34+ conn = await request ['connection' ].get_raw_connection ()
35+ # noinspection PyProtectedMember
36+ assert conn ._holder ._max_inactive_time == \
37+ _MAX_INACTIVE_CONNECTION_LIFETIME
2738 return text ('Hello, world!' )
2839
2940 @app .route ('/users/<uid:int>' )
You can’t perform that action at this time.
0 commit comments