mirror of
https://github.com/ha7ilm/openwebrx.git
synced 2026-04-07 23:43:45 +00:00
move the pump mechanism, allowing the old output code to be removed
This commit is contained in:
parent
4b36aca6fc
commit
9efe41a2b1
6 changed files with 29 additions and 81 deletions
|
|
@ -29,6 +29,20 @@ class Module(BaseModule, metaclass=ABCMeta):
|
|||
def getOutputFormat(self) -> Format:
|
||||
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 AutoStartModule(Module, metaclass=ABCMeta):
|
||||
def _checkStart(self) -> None:
|
||||
|
|
@ -47,20 +61,6 @@ 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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue