This commit is contained in:
Shital Shah 2023-08-30 00:47:36 -07:00
Родитель c9e5e9c0c4
Коммит 05121c60bf
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -7,6 +7,21 @@ from . import utils
from .lv_types import StreamItem from .lv_types import StreamItem
class Stream: class Stream:
"""
Stream allows you to write values into it. One stream can subscribe to many streams. When a value is
written in the stream, all subscribers also gets that value written into them (the from_steam parameter
is set to the source stream).
You can read values from a stream by calling read_all method. This will yield values as someone or subscribed streams are
writing into the stream. You can also load all values from the stream. The default stream won't load anything but
derived streams like file may load all values from the file and write into themselves.
You can think of stream as a pipe that can be chained to other pipees. As value is put in pipe, it travels through
connected pipes. The read_all method is like a tap that you can use to read values from the pipe. The load method is
for specialized streams that may generate values in that pipe.
Stream class supports full multi-threading.
"""
def __init__(self, stream_name:str=None, console_debug:bool=False): def __init__(self, stream_name:str=None, console_debug:bool=False):
self._subscribers = weakref.WeakSet() self._subscribers = weakref.WeakSet()
self._subscribed_to = weakref.WeakSet() self._subscribed_to = weakref.WeakSet()