summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2026-03-30 09:19:20 -0400
committerJacob Walls <jacobtylerwalls@gmail.com>2026-03-30 15:56:52 -0400
commit6c9ef6282e65a79daba4dc2146e8b825b4ddadb9 (patch)
tree9e2916cbccf0b8697e85326f76e6cc546886dafb
parent8f50bae618c435863f68b162135468a6f5ca7301 (diff)
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.)
-rw-r--r--django/test/testcases.py11
1 files 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):