fix: close stale DB connections before first query

This commit is contained in:
Jake 2026-03-07 00:22:19 -08:00
parent 3761a7cb21
commit 519b568ccb

View file

@ -9,6 +9,7 @@ import traceback
import django
from django.conf import settings
import django.db
from django.db import connection
from django.db.utils import OperationalError
from django.utils.translation import gettext as _
@ -187,6 +188,10 @@ class EvenniaServerService(MultiService):
# clear server startup mode
try:
# Close stale DB connections inherited from the pre-fork parent
# process. Python 3.14's sqlite3 module is not fork-safe and will
# raise MemoryError if a pre-fork connection is reused.
django.db.connections.close_all()
evennia.ServerConfig.objects.conf("server_starting_mode", delete=True)
except OperationalError:
print("Server server_starting_mode couldn't unset - db not set up.")