diff --git a/neon_mq_connector/consumers/select_consumer.py b/neon_mq_connector/consumers/select_consumer.py index bd77e46..b41e161 100644 --- a/neon_mq_connector/consumers/select_consumer.py +++ b/neon_mq_connector/consumers/select_consumer.py @@ -248,7 +248,8 @@ def _close_connection(self, mark_consumer_as_dead: bool = True): def reconnect(self, wait_interval: int = 5): self._close_connection(mark_consumer_as_dead=False) - # TODO: Find a better way to wait for shutdown/server restart + # TODO: Find a better way to wait for shutdown/server restart. This will + # fail to reconnect if the server isn't back up within `wait_interval` time.sleep(wait_interval) self.run() diff --git a/tests/test_consumers.py b/tests/test_consumers.py index 8f38eb8..91744d4 100644 --- a/tests/test_consumers.py +++ b/tests/test_consumers.py @@ -198,6 +198,7 @@ def test_handle_reconnection(self): test_thread.on_close.assert_not_called() self.rmq_instance.stop() + sleep(1) # Wait for the client to finish disconnecting test_thread.on_close.assert_called_once() self.assertFalse(test_thread.is_consuming) self.assertTrue(test_thread.is_consumer_alive)