import asyncio from lbry.dht.constants import generate_id from lbry.dht.node import Node from lbry.dht.peer import PeerManager from lbry.extras.daemon.storage import SQLiteStorage from lbry.conf import Config import logging logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)-4s %(name)s:%(lineno)d: %(message)s") log = logging.getLogger(__name__) async def do_it(): loop = asyncio.get_event_loop() #loop.set_debug(True) conf = Config() print(str(conf)) storage = SQLiteStorage(conf, ":memory:", loop, loop.time) await storage.open() node = Node( loop, PeerManager(loop), generate_id(), 4444, 4444, 4444, None, storage=storage ) node.start(interface='0.0.0.0', known_node_urls=conf.known_dht_nodes) await asyncio.sleep(10) key = bytes.fromhex('2ecce30223bc2808bd10cf8e18f1cccecedf9fd35fcc370b9d15ad7473a59d3dc16e85a8f08a1891e668608d1660b8c7') while True: print('PRE_SEARCH---') values = node.get_iterative_value_finder(key=key, max_results=1) print('PAUSE---') await asyncio.sleep(5) try: i = 0 print('SEARCH---') async for _ in values: print(f'{i}: {_}') i += 1 break finally: print('ACLOSE---') await values.aclose() print('PAUSE---') await asyncio.sleep(5) await asyncio.wait(asyncio.all_tasks()) if __name__ == '__main__': asyncio.run(do_it())