Merge pull request #1743 from unaizalakain/ticket_21172

Fixed #21172 -- have LiveServerThread follow the semantics of threading.Thread.join()
This commit is contained in:
Anssi Kääriäinen 2013-11-09 00:41:26 -08:00
commit 1830f50493
1 changed files with 5 additions and 2 deletions

View File

@ -1068,12 +1068,14 @@ class LiveServerThread(threading.Thread):
self.error = e self.error = e
self.is_ready.set() self.is_ready.set()
def join(self, timeout=None): def terminate(self):
"""
Shuts down live WSGI server.
"""
if hasattr(self, 'httpd'): if hasattr(self, 'httpd'):
# Stop the WSGI server # Stop the WSGI server
self.httpd.shutdown() self.httpd.shutdown()
self.httpd.server_close() self.httpd.server_close()
super(LiveServerThread, self).join(timeout)
class LiveServerTestCase(TransactionTestCase): class LiveServerTestCase(TransactionTestCase):
@ -1153,6 +1155,7 @@ class LiveServerTestCase(TransactionTestCase):
# reasons has raised an exception. # reasons has raised an exception.
if hasattr(cls, 'server_thread'): if hasattr(cls, 'server_thread'):
# Terminate the live server's thread # Terminate the live server's thread
cls.server_thread.terminate()
cls.server_thread.join() cls.server_thread.join()
# Restore sqlite connections' non-sharability # Restore sqlite connections' non-sharability