From 6c9ef6282e65a79daba4dc2146e8b825b4ddadb9 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 30 Mar 2026 09:19:20 -0400 Subject: Refs #36770 -- Guarded against an endless wait in LiveServerThread.terminate(). terminate() shouldn't assume the main server was started. (A deadlock from mishandling of in-memory SQLite databases may have occurred.) --- django/test/testcases.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/django/test/testcases.py b/django/test/testcases.py index de2a3eb61d..b31e70d9d1 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -1783,11 +1783,12 @@ class LiveServerThread(threading.Thread): ) def terminate(self): - if hasattr(self, "httpd"): - # Stop the WSGI server - self.httpd.shutdown() - self.httpd.server_close() - self.join() + if self.is_ready.is_set(): + if hasattr(self, "httpd"): + # Stop the WSGI server + self.httpd.shutdown() + self.httpd.server_close() + self.join() class LiveServerTestCase(TransactionTestCase): -- cgit v1.3