Exemple #1
0
    def __init__(self,
                 manager: ExecutorManager,
                 signing_key: str,
                 ip,
                 name='Node'):
        super().__init__()
        self.log = get_logger("{}.Composer".format(name))
        self.manager = manager
        self.ip = ip
        self.signing_key = signing_key
        self.verifying_key = wallet.get_vk(self.signing_key)

        self.overlay_fut = asyncio.ensure_future(
            OverlayInterface.event_listener(self._handle_overlay_event))
        self.command_queue = {}  # dict of UUID to kwargs
        self.pending_commands = deque(
        )  # To hold commands until the event loop is started

        # The 'future' task to flush pending_commands when event loop starts
        self.flush_pending_fut = asyncio.ensure_future(
            self._flush_pending_commands())
Exemple #2
0
        def _send_msg():
            def _e_handler(e):
                OverlayInterface._test_res = e

            def _thread():
                asyncio.set_event_loop(l)
                OverlayInterface.get_node_from_vk('fsdfhsdfkjsdh')

            def _assert():
                self.assertTrue(OverlayInterface._test_res['event'],
                                'not_found')
                l.call_soon_threadsafe(l.stop)
                th.join()
                th_a.join()

            l = asyncio.new_event_loop()
            asyncio.set_event_loop(l)
            asyncio.ensure_future(OverlayInterface.event_listener(_e_handler))
            th = Timer(0.01, _thread)
            th.start()
            th_a = Timer(0.05, _assert)
            th_a.start()
            l.run_forever()
Exemple #3
0
        def _send_msg():
            def _e_handler(e):
                OverlayInterface._test_res = e

            def _thread():
                asyncio.set_event_loop(l)
                OverlayInterface.get_node_from_vk(
                    '82540bb5a9c84162214c5540d6e43be49bbfe19cf49685660cab608998a65144'
                )

            def _assert():
                self.assertEqual(OverlayInterface._test_res['ip'], '127.0.0.1')
                l.call_soon_threadsafe(l.stop)
                th.join()
                th_a.join()

            l = asyncio.new_event_loop()
            asyncio.set_event_loop(l)
            asyncio.ensure_future(OverlayInterface.event_listener(_e_handler))
            th = Timer(0.01, _thread)
            th.start()
            th_a = Timer(0.05, _assert)
            th_a.start()
            l.run_forever()