Boilerplate Code for Stream Processing Block
Following code is the least required code to write a Block that processes in Stream mode.
# This is done for only one instance to to exist
from pipelineblocksdk.api.Singleton import Singleton
from pipelineblocksdk.construct.base.StreamBlock import StreamBlock
# Following code is the definition for a stream block
class MyBlock(StreamBlock, Singleton):
# This is the entrypoint for the block. This is a mandatory function.
def run(self):
#Your one time initialization code goes here
print('Run function says: Hello, world!')
self.stream()
@async
# @async is used to run the block in asynchronous mode
def stream(self):
#Your stream code goes here
print('Stream function says: Hello, world!')