Skip to content

Commit

Permalink
Made runserver close database connections from migration checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
apollo13 authored and felixxm committed Mar 1, 2024
1 parent daf7d48 commit bcccea3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions django/core/management/commands/runserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.servers.basehttp import WSGIServer, get_internal_wsgi_application, run
from django.db import connections
from django.utils import autoreload
from django.utils.regex_helper import _lazy_re_compile

Expand Down Expand Up @@ -134,6 +135,9 @@ def inner_run(self, *args, **options):
# Need to check migrations here, so can't use the
# requires_migrations_check attribute.
self.check_migrations()
# Close all connections opened during migration checking.
for conn in connections.all(initialized_only=True):
conn.close()

try:
handler = self.get_handler(*args, **options)
Expand Down

0 comments on commit bcccea3

Please sign in to comment.