def _build_url(self, protocol, port, ip='', vk=''): assert protocol in ( 'ipc', 'tcp' ), "Got protocol {}, but only tcp and ipc are supported".format( protocol) if vk and not ip: node = OverlayInterface.get_node_from_vk(vk) self.log.critical(node) return "{}://{}:{}".format(protocol, ip, port)
def _func(self, *args, **kwargs): contains_vk = 'vk' in kwargs and kwargs['vk'] contains_ip = 'ip' in kwargs and kwargs['ip'] if contains_vk and not contains_ip: # We can't call get_node_from_vk if the event loop is not running, so we add it to pending commands if not asyncio.get_event_loop().is_running(): self.log.debugv( "Cannot execute vk lookup yet as event loop is not running. Adding func {} to command " "queue".format(func.__name__)) self.pending_commands.append((func.__name__, args, kwargs)) return cmd_id = OverlayInterface.get_node_from_vk(kwargs['vk']) assert cmd_id not in self.command_queue, "Collision! Uuid {} already in command queue {}".format( cmd_id, self.command_queue) self.log.debugv( "Looking up vk {}, which returned command id {}".format( kwargs['vk'], cmd_id)) self.command_queue[cmd_id] = (func.__name__, args, kwargs) # If the 'ip' key is already set in kwargs, no need to do a lookup else: func(self, *args, **kwargs)
def _thread(): asyncio.set_event_loop(l) OverlayInterface.get_node_from_vk( '82540bb5a9c84162214c5540d6e43be49bbfe19cf49685660cab608998a65144' )
def _thread(): asyncio.set_event_loop(l) OverlayInterface.get_node_from_vk('fsdfhsdfkjsdh')
from cilantro.protocol.overlay.interface import OverlayInterface from cilantro.logger.base import get_logger from threading import Thread import asyncio log = get_logger(__name__) def event_handler(e): log.important(e) OverlayInterface.start_service(sk='06391888e37a48cef1ded85a375490df4f9b2c74f7723e88c954a055f3d2685a') node = OverlayInterface.get_node_from_vk(vk='82540bb5a9c84162214c5540d6e43be49bbfe19cf49685660cab608998a65144')