tweak db connection settings

This commit is contained in:
Izalia Mae 2020-02-18 01:21:57 -05:00
parent 859fde7648
commit 03a0c423be
2 changed files with 5 additions and 4 deletions

View file

@ -50,7 +50,7 @@ else:
#DBUSER=$USER
#DBPASS=
#DBTABLE=uncia
#DBCONNUM=10
#DBCONNUM=25
# Web forward config
SECRET={ranchars}
@ -60,10 +60,10 @@ SECRET={ranchars}
newenvfile.write(newenv)
try:
db_connection_count = int(env.get('DBCONNUM', 10))
db_connection_count = int(env.get('DBCONNUM', 25))
except:
db_connection_count = 10
db_connection_count = 25
dbconfig = {
'host': env.get('DBHOST'),

View file

@ -33,7 +33,8 @@ def dbconn(database, pooled=True):
})
if pooled:
return PooledPg(dbconfig['connum'], maxusage=None, **options)
cached = 5 if dbconfig['connum'] >= 5 else 0
return PooledPg(maxconnections=dbconfig['connum'], mincached=cached, maxusage=2, **options)
else:
return pg.DB(**options)