diff --git a/LCS/Messaging/python/common/util.py b/LCS/Messaging/python/common/util.py index 100ac836e25b23d1098cdb72ab533dd91a567295..3664c82cb8ea86ebe611c2a692a47e92d45d3dd9 100644 --- a/LCS/Messaging/python/common/util.py +++ b/LCS/Messaging/python/common/util.py @@ -25,6 +25,7 @@ This package contains different utilities that are common for LOFAR software """ import sys +import time def check_bit(value, bit): @@ -112,3 +113,16 @@ def isFloatList(lst): if not isinstance(lst, list): return False return all(isinstance(x, float) for x in lst) + + +def waitForInterrupt(): + """ + Useful (low cpu load) loop that waits for keyboard interrupt. + """ + while True: + try: + time.sleep(10) + except KeyboardInterrupt: + break + + diff --git a/LCS/Messaging/python/messaging/Service.py b/LCS/Messaging/python/messaging/Service.py index 1c759817b8d78fd4eb6923dec9e1d58a7833b97b..6f5e179845dd1b99657e1631f8b6c65cfe5bca9f 100644 --- a/LCS/Messaging/python/messaging/Service.py +++ b/LCS/Messaging/python/messaging/Service.py @@ -210,19 +210,6 @@ class Service(object): self.connected = False - def wait_for_interrupt(self): - """ - Useful (low cpu load) loop that waits for keyboard interrupt. - """ - looping = True - while looping: - try: - time.sleep(10) - except KeyboardInterrupt: - looping = False - logger.info("Keyboard interrupt received.") - - def __enter__(self): """ Internal use only. Handles scope with keyword 'with'