MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / prefetch_mirror

Function prefetch_mirror

aura/prefetch.py:40–81  ·  view source on GitHub ↗
(uris: Iterable[str], workers=10)

Source from the content-addressed store, hash-verified

38
39
40def prefetch_mirror(uris: Iterable[str], workers=10):
41 logger.info("Caching AST patterns")
42 cache.ASTPatternCache.proxy()
43
44 logger.info("Caching list of packages on pypi")
45 cache.PyPIPackageList.proxy()
46
47 #logger.info("Prefetching package JSON information")
48 #lm = mirror.LocalMirror()
49 #pkgs = tuple(lm.list_packages())
50 #for x in tqdm.tqdm(pkgs, leave=False):
51 # lm.get_json(x)
52
53 loop = asyncio.get_event_loop()
54
55 pf = github.GitHubPrefetcher()
56 loop.create_task(pf.process())
57
58 uri_queue = AsyncQueue(desc="Mirror package prefetch")
59
60 workers = [loop.create_task(fetch_package(uri_queue, pf)) for _ in range(workers)]
61
62 for uri in uris:
63 uri_queue.put_nowait(uri)
64
65 logger.info("Waiting for prefetch workers to finish")
66
67 loop.run_until_complete(uri_queue.join())
68
69 # Cancel prefetch workers
70 for worker in workers:
71 worker.cancel()
72
73 # Wait for all tasks to finish
74 logger.info("All coroutines spawned, waiting for work to finish...")
75 loop.run_until_complete(pf.queue.put(github.GitHubPrefetcher.STOP))
76
77 pending = asyncio.all_tasks(loop=loop)
78 loop.run_until_complete(asyncio.gather(*pending))
79
80 loop.stop()
81 loop.close()
82
83
84

Callers

nothing calls this directly

Calls 7

processMethod · 0.95
put_nowaitMethod · 0.95
joinMethod · 0.95
AsyncQueueClass · 0.85
fetch_packageFunction · 0.85
putMethod · 0.80
proxyMethod · 0.45

Tested by

no test coverage detected