def _construct_pipes(core_classes_map):
"""Creates all the pipes needed to connect the cores"""
# Create the first pipe
receiver, sender = Pipe(duplex=False)
# The input pipe of the pipeline is the sender end (introduced the packages to the first core)
input_pipe = sender
for core_class in core_classes_map:
# If no kwargs passed, initialize as empty object
if Pipeline.KEY_KWARGS not in core_class:
core_class[Pipeline.KEY_KWARGS] = {}
# The input pipe of a core is the end that receives packages
core_class[Pipeline.KEY_KWARGS]['pipe_in'] = receiver
# Create the inter-core pipe
receiver, sender = Pipe(duplex=False)
# The output pipe of a core is the end that sends the result
core_class[Pipeline.KEY_KWARGS]['pipe_out'] = sender
# The output pipe of the pipeline is the receiver end of the last core (in order to receive its result)
output_pipe = receiver
return input_pipe, output_pipe
评论列表
文章目录