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):
113
113
max_size = app .config .setdefault ('DB_POOL_MAX_SIZE' , 10 ),
114
114
ssl = app .config .setdefault ('DB_SSL' ),
115
115
loop = loop ,
116
+ ** app .config .setdefault ('DB_KWARGS' , dict ()),
116
117
)
117
118
118
119
@app .listener ('after_server_stop' )
Original file line number Diff line number Diff line change 8
8
9
9
from .models import DB_ARGS , PG_URL
10
10
11
+ _MAX_INACTIVE_CONNECTION_LIFETIME = 59.0
12
+
11
13
12
14
# noinspection PyShadowingNames
13
15
async def _app (config ):
14
16
app = sanic .Sanic ()
15
17
app .config .update (config )
18
+ app .config .update ({
19
+ 'DB_KWARGS' : dict (
20
+ max_inactive_connection_lifetime = _MAX_INACTIVE_CONNECTION_LIFETIME ,
21
+ ),
22
+ })
16
23
17
24
db = Gino (app )
18
25
@@ -24,6 +31,10 @@ class User(db.Model):
24
31
25
32
@app .route ('/' )
26
33
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
27
38
return text ('Hello, world!' )
28
39
29
40
@app .route ('/users/<uid:int>' )
You can’t perform that action at this time.
0 commit comments