コード例 #1
0
    def __init__(self):
        # util
        self._connection = Connection.OneWayBusyBufferingMappedFileConnection()
        self._collector = Collector.TypedCollector(self._connection)
        self._counter = 0

        #parameters
        self._parameters = []

        #sets
        self._sources = []
        self._sets = []
        self._sinks = []

        #specials
        self._broadcast = []
コード例 #2
0
    def execute(self, local=False, debug=False):
        """
        Triggers the program execution.

        The environment will execute all parts of the program that have resulted in a "sink" operation.
        """
        if debug:
            local = True
        self._local_mode = local
        self._debug_mode = debug
        self._optimize_plan()

        plan_mode = sys.stdin.readline().rstrip('\n') == "plan"

        if plan_mode:
            output_path = sys.stdin.readline().rstrip('\n')
            self._connection = Connection.OneWayBusyBufferingMappedFileConnection(
                output_path)
            self._collector = Collector.TypedCollector(self._connection, self)
            self._send_plan()
            self._connection._write_buffer()
        else:
            import struct
            operator = None
            try:
                port = int(sys.stdin.readline().rstrip('\n'))

                id = int(sys.stdin.readline().rstrip('\n'))
                input_path = sys.stdin.readline().rstrip('\n')
                output_path = sys.stdin.readline().rstrip('\n')

                operator = None
                for set in self._sets:
                    if set.id == id:
                        operator = set.operator
                    if set.id == -id:
                        operator = set.combineop
                operator._configure(input_path, output_path, port, self)
                operator._go()
                sys.stdout.flush()
                sys.stderr.flush()
            except:
                sys.stdout.flush()
                sys.stderr.flush()
                if operator is not None:
                    operator._connection._socket.send(struct.pack(">i", -2))
                raise