async def mount(module, path, *, loop=None): s = ZMQServer(loop=loop) s.set_module(module) s.start() dht = await getDHT() await asyncio.sleep(0.1) addr = 'tcp://%s:%d' % (getHostIP(), s.port) await dht.set(path, addr) return s
def saveDHTNodes(): if __dht is None: return if not config_dir().exists(): config_dir().mkdir(parents=True) kad = config_dir() / 'kad.dat' nodes = __dht.bootstrappable_neighbors() nodes.append((getHostIP(), __dht.port)) kad.write_text('\n'.join( ["kad://%s:%d" % (node[0], node[1]) for node in set(nodes)])) loop = asyncio.get_event_loop() loop.call_later(600, saveDHTNodes)
async def mount(module, path, *, loop=None): s = ZMQServer(loop=loop) s.set_module(module) s.start() await asyncio.sleep(0.1, loop=loop) addr = 'tcp://%s:%d' % (getHostIP(), s.port) try: _setAddressOnRedis(path, addr) except RedisNotSetError: pass dht = await getDHT() await dht.set(path, addr) return s
def __init__(self): super().__init__() self.host = getHostIP()