Advertisement
giuseppe1977

Untitled

Feb 12th, 2025
4
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. # Adds a delay to wait for daemon to be started before connect. Gentoo bug 934153
  2. # https://github.com/greenbone/ospd-openvas/pull/1026
  3. --- a/tests/messaging/test_mqtt.py
  4. +++ b/tests/messaging/test_mqtt.py
  5. @@ -91,7 +91,17 @@ class MQTTDaemonTestCase(TestCase):
  6.  
  7. daemon = MQTTDaemon(client)
  8.  
  9. - daemon.run()
  10. + max_attempts = 5
  11. + attempts = 0
  12. + while attempts < max_attempts:
  13. + try:
  14. + daemon.run()
  15. + break
  16. + except AssertionError:
  17. + attempts += 1
  18. + time.sleep(1)
  19. + if attempts == 4:
  20. + sys.exit("Timeout waiting MQTTDaemon")
  21.  
  22. client.connect.assert_called_with()
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement