Example #1
0
    def __init_broadcast_scheduler(self):
        scheduler = BroadcastScheduler(channel=ChannelProperty().name, self_target=ChannelProperty().peer_target)
        scheduler.start()

        self.__broadcast_scheduler = scheduler

        future = scheduler.schedule_job(BroadcastCommand.SUBSCRIBE, ChannelProperty().peer_target)
        future.result(conf.TIMEOUT_FOR_FUTURE)
Example #2
0
    def test_broadcast_process(self):
        ## GIVEN
        broadcast_scheduler = BroadcastScheduler()
        broadcast_scheduler.start()

        ## WHEN
        times = 0
        while times < 2:
            future = broadcast_scheduler.schedule_job("status", "param")
            print(f'broadcast_process status : {future.result()}')

            time.sleep(1)
            times += 1

        broadcast_scheduler.stop()
        broadcast_scheduler.wait()
    def __init__(self, tx_versioner: TransactionVersioner,
                 broadcast_scheduler: BroadcastScheduler,
                 crash_callback_in_join_thread):
        super().__init__()

        self.__broadcast_queue = self.Queue()
        self.__broadcast_queue.cancel_join_thread()

        args = (ChannelProperty().name, StubCollection().amqp_target,
                StubCollection().amqp_key, ChannelProperty().peer_target,
                tx_versioner, self.__broadcast_queue)
        super().start(
            target=ChannelTxCreatorInnerService.main,
            args=args,
            crash_callback_in_join_thread=crash_callback_in_join_thread)

        self.__broadcast_scheduler = broadcast_scheduler
        commands = (BroadcastCommand.SUBSCRIBE, BroadcastCommand.UNSUBSCRIBE)
        broadcast_scheduler.add_schedule_listener(self.__broadcast_callback,
                                                  commands=commands)
Example #4
0
    def __start_broadcast_scheduler(self, channel):
        scheduler = BroadcastScheduler(channel=channel)
        scheduler.start()

        self.__broadcast_schedulers[channel] = scheduler
        return scheduler