mirror of
https://github.com/OMGeeky/flucto-heisskleber.git
synced 2025-12-30 00:03:59 +01:00
* WIP: Added async file reader. * Async resampling and synchronization refactored. * Add async mqtt publisher. Remove queue from joint. * Add async zmq publisher and subscriber. * Modify integration tests for streaming. * Name refactoring resampler. * Added async source/sink to factory. * Refactor joint and add integration tests. * Add termcolor dev dependency * Add conosole source and sink * Add cli interface for different protocols * Removed files unfit for merge. * Fix review requests. * Restore use of $MSB_CONFIG_DIR for now. It seems that the default behaviour is not looking for .config/heisskleber * Remove version test, causing unnecessary failures.
35 lines
911 B
Python
35 lines
911 B
Python
import json
|
|
import sys
|
|
import time
|
|
from queue import SimpleQueue
|
|
from threading import Thread
|
|
|
|
from heisskleber.core.types import Serializable, Source
|
|
|
|
|
|
class ConsoleSource(Source):
|
|
def __init__(self, topic: str | list[str] | tuple[str] = "console") -> None:
|
|
self.topic = "console"
|
|
self.queue = SimpleQueue()
|
|
self.listener_daemon = Thread(target=self.listener_task, daemon=True)
|
|
self.listener_daemon.start()
|
|
self.pack = json.loads
|
|
|
|
def listener_task(self):
|
|
while True:
|
|
data = sys.stdin.readline()
|
|
payload = self.pack(data)
|
|
self.queue.put(payload)
|
|
|
|
def receive(self) -> tuple[str, dict[str, Serializable]]:
|
|
data = self.queue.get()
|
|
return self.topic, data
|
|
|
|
|
|
if __name__ == "__main__":
|
|
console_source = ConsoleSource()
|
|
|
|
while True:
|
|
print(console_source.receive())
|
|
time.sleep(1)
|