diff --git a/csdr/module.py b/csdr/module.py index 97cb131..7ade431 100644 --- a/csdr/module.py +++ b/csdr/module.py @@ -47,6 +47,20 @@ class AutoStartModule(Module, metaclass=ABCMeta): def start(self): pass + def pump(self, read, write): + def copy(): + while True: + data = None + try: + data = read() + except ValueError: + pass + if data is None or isinstance(data, bytes) and len(data) == 0: + break + write(data) + + return copy + class ThreadModule(AutoStartModule, Thread, metaclass=ABCMeta): def __init__(self): @@ -113,17 +127,3 @@ class PopenModule(AutoStartModule, metaclass=ABCMeta): self.process.wait() self.process = None self.reader.stop() - - def pump(self, read, write): - def copy(): - while True: - data = None - try: - data = read() - except ValueError: - pass - if data is None or isinstance(data, bytes) and len(data) == 0: - break - write(data) - - return copy diff --git a/owrx/aprs/module.py b/owrx/aprs/module.py index ddbbde6..22eac4a 100644 --- a/owrx/aprs/module.py +++ b/owrx/aprs/module.py @@ -74,17 +74,3 @@ class DirewolfModule(AutoStartModule): self.process.wait() self.process = None self.reader.stop() - - def pump(self, read, write): - def copy(): - while True: - data = None - try: - data = read() - except ValueError: - pass - if data is None or isinstance(data, bytes) and len(data) == 0: - break - write(data) - - return copy