busy_script.py 860 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. __author__ = "Christian Heider Nielsen"
  4. __doc__ = r"""
  5. Created on 31-10-2020
  6. """
  7. from warg import IgnoreInterruptSignal, busy_indicator
  8. def asd() -> None:
  9. """
  10. :rtype: None
  11. """
  12. import time
  13. next_reading = time.time()
  14. with IgnoreInterruptSignal():
  15. print("Publisher started")
  16. for _ in busy_indicator():
  17. next_reading += 3
  18. sleep_time = next_reading - time.time()
  19. if sleep_time > 0:
  20. time.sleep(sleep_time)
  21. if __name__ == "__main__":
  22. if False:
  23. from pathlib import Path
  24. from draugr.os_utilities.linux_utilities.systemd_utilities.service_management import (
  25. install_service,
  26. )
  27. install_service(Path(__file__), "busy_script")
  28. else:
  29. asd()