Skip to content

Commit 406ab97

Browse files
authored
Merge pull request #1086 from readthedocs/davidfischer/make-pgpool-optional
Make pgpool optional
2 parents 31e9e05 + 9c2ef14 commit 406ab97

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

config/settings/production.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@
4040
# --------------------------------------------------------------------------
4141
DATABASES["default"] = env.db() # Raises ImproperlyConfigured if DATABASE_URL not set
4242

43+
# Enable database connection pooling
44+
# https://docs.djangoproject.com/en/dev/ref/databases/#connection-pool
45+
USE_DB_POOLING = env.bool("USE_DB_POOLING", default=False)
4346
for db in ("default", "replica"):
4447
if db in DATABASES:
45-
# Enable database connection pooling
46-
# https://docs.djangoproject.com/en/dev/ref/databases/#connection-pool
4748
if "OPTIONS" not in DATABASES[db]:
4849
DATABASES[db]["OPTIONS"] = {}
49-
if DATABASES[db]["ENGINE"] == "django.db.backends.postgresql":
50+
51+
if (
52+
DATABASES[db]["ENGINE"] == "django.db.backends.postgresql"
53+
and USE_DB_POOLING
54+
):
5055
DATABASES[db]["OPTIONS"]["pool"] = True
5156
else:
5257
# CONN_MAX_AGE should be 0 when using connection pooling

0 commit comments

Comments
 (0)