Exemplo n.º 1
0
        def get_measured_state(
                self,
                raw_termination_state: RawTerminationStates.TerminationState):
            termination_state = raw_termination_state.get_measured_state()

            if isinstance(termination_state, TerminationStates.InitState):
                return ZipStates.WaitOnLeftRight()
            else:
                return ZipStates.Stopped()
        def get_measured_state(
                self,
                raw_termination_state: RawTerminationStates.TerminationState):
            termination_state = raw_termination_state.get_measured_state()

            if isinstance(termination_state, TerminationStates.ErrorState):
                return MergeStates.Stopped()
            else:
                return MergeStates.RightReceived(elem=self.elem, ack=self.ack)
        def get_measured_state(
                self,
                raw_termination_state: RawTerminationStates.TerminationState):
            termination_state = raw_termination_state.get_measured_state()

            if isinstance(termination_state, TerminationStates.ErrorState):
                return MergeStates.Stopped()
            else:
                return MergeStates.BothReceivedContinueLeft(
                    left_elem=self.left_elem,
                    right_elem=self.right_elem,
                    left_ack=self.left_ack,
                    right_ack=self.right_ack)
        def get_measured_state(
                self,
                raw_termination_state: RawTerminationStates.TerminationState):
            meas_termination_state = raw_termination_state.get_measured_state()

            if any([
                    isinstance(meas_termination_state,
                               TerminationStates.BothCompletedState),
                    isinstance(meas_termination_state,
                               TerminationStates.ErrorState),
            ]):
                return MergeStates.Stopped()
            else:
                return MergeStates.NoneReceivedWaitAck()
Exemplo n.º 5
0
        def get_measured_state(
                self,
                raw_termination_state: RawTerminationStates.TerminationState):
            termination_state = raw_termination_state.get_measured_state()

            if any([
                    isinstance(termination_state,
                               TerminationStates.RightCompletedState),
                    isinstance(termination_state,
                               TerminationStates.ErrorState),
            ]):
                return ZipStates.Stopped()
            else:
                return ZipStates.WaitOnRight(left_ack=self.left_ack,
                                             left_iter=self.left_iter)
Exemplo n.º 6
0
    def _on_error_or_complete(
        self,
        next_final_state: RawTerminationStates.TerminationState,
        exc: Exception = None,
    ):
        with self.lock:
            raw_prev_final_state = self.termination_state
            raw_prev_state = self.state
            next_final_state.raw_prev_state = raw_prev_final_state
            self.termination_state = next_final_state

        prev_state = raw_prev_state.get_measured_state(raw_prev_final_state)
        curr_state = raw_prev_state.get_measured_state(next_final_state)

        if not isinstance(prev_state, ZipStates.Stopped) \
                and isinstance(curr_state, ZipStates.Stopped):
            self._signal_on_complete_or_on_error(prev_state, exc=exc)
        def get_measured_state(
                self,
                raw_termination_state: RawTerminationStates.TerminationState):
            termination_state = raw_termination_state.get_measured_state()

            if any([
                    isinstance(termination_state,
                               TerminationStates.LeftCompletedState),
                    isinstance(termination_state,
                               TerminationStates.ErrorState),
            ]):
                return ControlledZipStates.Stopped()
            else:
                return ControlledZipStates.WaitOnLeft(
                    right_val=self.right_val,
                    right_ack=self.right_ack,
                    right_iter=self.right_iter,
                )
Exemplo n.º 8
0
    def _on_error_or_complete(
            self,
            next_termination_state: RawTerminationStates.TerminationState,
            exc: Exception = None):
        with self.lock:
            next_termination_state.raw_prev_state = self.termination_state
            self.termination_state = next_termination_state

            raw_state = self.state

        prev_raw_termination_state = next_termination_state.raw_prev_state
        raw_termination_state = next_termination_state

        meas_prev_state = raw_state.get_measured_state(
            prev_raw_termination_state)
        meas_state = raw_state.get_measured_state(raw_termination_state)

        if not isinstance(meas_prev_state, MergeStates.Stopped) \
                and isinstance(meas_state, MergeStates.Stopped):
            self._signal_on_complete_or_on_error(meas_prev_state, exc)