diff --git a/spine_engine/server/engine_server.py b/spine_engine/server/engine_server.py index 21c9c70..bf9bbe0 100644 --- a/spine_engine/server/engine_server.py +++ b/spine_engine/server/engine_server.py @@ -83,7 +83,8 @@ def close(self): """Closes the server by sending a KILL message to this thread using a PAIR socket.""" if self.auth is not None: self.auth.stop() - time.sleep(0.2) # wait a bit until authenticator has been closed + while self.auth.is_alive(): + pass self.ctrl_msg_sender.send(b"KILL") self.join() # Wait for the thread to finish and sockets to close self.ctrl_msg_sender.close() # Close this in the same thread that it was created in diff --git a/tests/project_item/test_ExecutableItem.py b/tests/project_item/test_ExecutableItem.py index 2497704..1557200 100644 --- a/tests/project_item/test_ExecutableItem.py +++ b/tests/project_item/test_ExecutableItem.py @@ -10,10 +10,7 @@ # this program. If not, see . ###################################################################################################################### -""" -Unit tests for ExecutableItem. - -""" +""" Unit tests for ExecutableItem. """ from tempfile import TemporaryDirectory import unittest from unittest import mock diff --git a/tests/server/test_EngineServer.py b/tests/server/test_EngineServer.py index 2e21dab..ca85f5e 100644 --- a/tests/server/test_EngineServer.py +++ b/tests/server/test_EngineServer.py @@ -10,9 +10,7 @@ # this program. If not, see . ###################################################################################################################### -""" -Unit tests for EngineServer class. -""" +""" Unit tests for EngineServer class. """ import threading import unittest @@ -175,7 +173,7 @@ def test_engineserver_close(self): self.assertTrue(server.ctrl_msg_sender.closed) # PAIR socket should be closed self.assertTrue(server._context.closed) # Context should be closed self.assertFalse(server.is_alive()) # server thread should not be alive - self.assertEqual(threading.active_count(), 1) # Only one thread running after close + self.assertTrue(all(thread.name != "EngineServerThread" for thread in threading.enumerate())) if __name__ == "__main__":